Greatest.java
Aim:
To find greatest among two numbers using if-else
Source code:
import java.lang.*;
import java.util.*;
class Greatest
{
public static void main(String args[])
{
int a,b;
Scanner input=new Scanner(System.in);
System.out.println("Enter values for a,b");
a=input.nextInt();
b=input.nextInt();
if(a>b)
{
System.out.println("a is greater");
}
else
{
System.out.println("b is greater");
}
}
}
Output-1:
Enter values for a,b
13
25
b is greater
Output-2:
Enter values for a,b
125
88
a is greater
No comments:
Post a Comment