Prompt the user to provide two no. Using conditional operator to find the smallest no and print that no.

import java.util.*;
class CheckCondn
 {
  public static void main(String[] args)
  {
   int num1,num2;
   int i;
   Scanner in=new Scanner(System.in);
   System.out.println("enter the value of num1");
   num1=in.nextInt();
   System.out.println("enter the value of num");
   num2=in.nextInt();
   if(num1<num2)
     {
        System.out.println("num1 is smallest");
     }
   else
     {
        System.out.println("num2 is smallest");
     }
   }
}

No comments:

Post a Comment