Java Program To Find Minimum among 3 Numbers

Here we have a simple java prpgram to find a minimum among 3 numbers where input is taken from the user and compare all the integers and show the minimum among all.

Java Program To Find Minimum of 3 numbers
import java.util.Scanner;
class Minimum
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a,b,c;
System.out.print("Enter 3 numbers : ");
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
System.out.print("Minimum : ");
if(a<b)
if(a<c)
System.out.print(a);
else
System.out.print(c);
else
if(b<c)
System.out.print(b);
else
System.out.print(c);
}
}
OUTPUT:
Enter 3 numbers : 4  1  3
Minimum : 1


tags: java , java program , java language , c , programs  of c , c++ , programs of c++ , tutorialspoint , java tutorialspoint , code camp , learn java.

Post a Comment

Previous Post Next Post