Java Program to Find Largest of Three Numbers

Java program to find Largest of Three Numbers

import java.util.Scanner;  
public class LargestNumberExample1  
public static void main(String[] args)   
int a, b, c, largest, temp;  
//object of the Scanner class  
Scanner sc = new Scanner(;  
//reading input from the user  
System.out.println("Enter the first number:");  
a = sc.nextInt();  
System.out.println("Enter the second number:");  
b = sc.nextInt();  
System.out.println("Enter the third number:");  
c = sc.nextInt();  
//comparing a and b and storing the largest number in a temp variable  
//comparing the temp variable with c and storing the result in the variable  
//prints the largest number  
System.out.println("The largest number is: "+largest);  


Enter the first number:
Enter the second number:
Enter the third number:
The largest number is: 65
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment