**Question 5 : Write a program in Java to find the greatest and the smallest number among three numbers given by the user.**

**Java Program :**

public class greatest_of_three

{

public static void main(int a,int b,int c)

{

int d=0;

int e=0;

if (a>b && a>c)

d=a;

if (b>a && b>c)

d=b;

if (c>a && c>b)

d=c;

if (a<b && a<c)

e=a;

if (b<a && b<c)

e=b;

if (c<a && c<b)

e=c;

System.out.println("Among the inputs done i.e. "+a+","+b+","+c);

System.out.println("The greatest number = "+d);

System.out.println("The smallest number = "+e);

}

}

**Input :**

a=10

b=20

c=30

**Output :**

Among the inputs done i.e. 10,20,30

The greatest number = 30

The smallest number = 10

Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

ReplyDelete