Computer Science, asked by sp2003, 1 year ago

write a program in java to input and arrange 3 numbers in ascending order without using arrays/ functions.
Please be accurate and check the program before posting it.It's urgent
Ps. In 9th grade level


sp2003: it should work for negative numbers also

Answers

Answered by Anonymous
2
import java.util.*;
class TeraBhalaHo
{public static void main()
{Scanner Sc= new Scanner(System.in);
int a= Sc.nextInt();
int b=Sc.nextInt();
int c= Sc.nextInt();

if(a>b && a>c)
{if(b>c)
{System.out.println( c+ " " +b+ " "+a);
}
else
{System.out.println(b+ " " +c+ " " +a);
}
}
else if (b>a && b>c)
{if(a>c)
{System.out.println( c+ " " +a+ " "+b);
}
else
{System.out.println( a+ " " +c+ " "+b);
}
}
else
{if (b>a)
{System.out.println( a+ " " +b+ " "+c);
}
else
{System.out.println( b+ " " +a+ " "+c);
}
}

}
}


Hope it helps u...
If yes, mark brainliest...
have a gr8 day ahead...

@TeraBhalaHo

sp2003: Thank you so much! It worked
Anonymous: u r welcome..
Anonymous: @ApkaBhalaHo
sp2003: what do you study?
Anonymous: i am in class 11 yet not my classes have not started
Anonymous: btw in computer, i study JAVA
sp2003: you did icse in 10th?
Anonymous: yes
sp2003: ohk
sp2003: where are you studying?
Similar questions