How to find greater number using if-else

//How to find greater number using if-else


import java.util.*;
public class M
{
public static void main(String args[])
{
int a,b;
Scanner scan=new Scanner(System.in);
System.out.println("Enter the value of a:");
a=scan.nextInt();
System.out.println("Enter the value of b:");
b=scan.nextInt();

if(a>b)
{
System.out.println("a is greater than b");
}
else
{
System.out.println("b is greater than a");
}
}
}


OUTPUT:
Enter the value of a:
12
Enter the value of b:
21
b is greater than a

No comments:

Post a Comment