Program to find smallest and largest between three numbers using Java.
public class MaximumAndMinimum {
public static void main(String[] args) {
int no1=200, no2=45, no3=100;
if(no1< no2 && no1< no3){
System.out.println("First number is smallest : "+no1);
}
else if(no2< no1 && no2< no3){
System.out.println("Second number is smallest : "+no2);
}
else{
System.out.println("Third number is smallest : "+no3);
}
if(no1> no2 && no1> no3){
System.out.println("First number is Greatest : "+no1);
}
else if(no2> no1 && no2> no3){
System.out.println("Second number is Greatest : "+no2);
}
else{
System.out.println("Third number is Greatest : "+no3);
}
}
}
Comments
Post a Comment