java program for to find largest among three numbers
import java.io.*;
import java.util.*;
class largest_number{
public static void main(String args[]){
int num1,num2,num3;
System.out.println("Enter three numbers one by one");
Scanner sc=new Scanner(System.in);
num1=sc.nextInt();
num2=sc.nextInt();
num3=sc.nextInt();
if(num1>num2 && num1>num3)
System.out.println("The greater number is\n"+num1);
if(num2>num1 && num2>num3)
System.out.println("The greater number is\n"+num2);
if(num3>num1 && num3>num2)
System.out.println("The greater number is\n"+num3);
}
}
OUTPUT-
Enter three numbers one by one
6
9
8
The greater number is
9
import java.util.*;
class largest_number{
public static void main(String args[]){
int num1,num2,num3;
System.out.println("Enter three numbers one by one");
Scanner sc=new Scanner(System.in);
num1=sc.nextInt();
num2=sc.nextInt();
num3=sc.nextInt();
if(num1>num2 && num1>num3)
System.out.println("The greater number is\n"+num1);
if(num2>num1 && num2>num3)
System.out.println("The greater number is\n"+num2);
if(num3>num1 && num3>num2)
System.out.println("The greater number is\n"+num3);
}
}
OUTPUT-
Enter three numbers one by one
6
9
8
The greater number is
9
Comments
Post a Comment