Write a program in a java to find the largest number among the two number
Answers
Answered by
1
Answer:
Program:-
import java.util*;
public class Largest
{
public static void main(String arts[ ])
{
Scanner in=new Scanner(System.in);
int a,b,c=0;
System.out.println("Enter the numbers");
a=in.nextInt();
b=in.nextInt();
c=Math.max(a,b);
System.out.println("The greater number="+c);
}
}
OR:-
import java.util*;
public class Largest
{
public static void main(String arts[ ])
{
Scanner in=new Scanner(System.in);
int a,b;
System.out.println("Enter the numbers");
a=in.nextInt();
b=in.nextInt();
if(a>b)
{
System.out.println("Greater number="+a);
}
else
System.out.println("Greater number="+b);
}
}
Similar questions