Java program to find the largest of three numbers

In this tutorial you will learn how to write a program in C to find largest of three numbers.


Read This: C program to find greatest among three.

Suppose if someone give 3 numbers as input 12, 15 and 10 then our program should return 15 as a output because 15 is a greatest among three.

Java program to find greatest of three numbers

import java.util.*;  
class Main{
    public static void main(String ...args){
        Scanner sc= new Scanner(;
        System.out.print("Enter first number- ");  
        int a= sc.nextInt();  
        System.out.print("Enter second number- ");  
        int b= sc.nextInt();  
        System.out.print("Enter third number- ");  
        int c= sc.nextInt();  
        if(a>=b && a>=c)
    		System.out.println(" a is greatest");
    	if(b>=a && b>=c)
    		System.out.println(" b is greatest");
    	if(c>=a && c>=b)
    		System.out.println("c is gretest");


java program to find greatest number among three

Leave a Comment