Q. Write a program in java to find the largest of three integers?
import java.util.Scanner;
class large
{
public static void main(String args[])
{
int b,a,c;
Scanner sc=new Scanner(System.in);
System.out.println("enter three numbers=");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a>b && a>c)
System.out.println("the largest value is="+a);
else if(b>c && b>a)
System.out.println("the largest value is="+b);
else
System.out.println("the largest value is="+c);
}
}
Output :
enter three numbers = 4 9 7
the largest value is= 9
/*if you have any problem, comment below*/
Comments
Post a Comment