C Program to find greatest in three numbers


This problem may be solved by different patterns.Here we are providing the simplest method to find the greatest number between three numbers. It can also be solved by nested if statement, else if ladder statement.

C Program to find greatest in 3 numbers Simply Define

#include<stdio.h> void main(){ clrscr(); int a,b,c; printf("enter two number"); scanf("%d %d %d &a &b &c"); if (a>b & &a>c); { printf("a Is Gratest"); } else if(b>c) { printf("b Is Gratest"); } else { printf("c Is Gratest"); } getch(); }

Output:-

Enter three number 10 20 30
C is greatest number

Explanation of Program :

In this program,we are taking three input number as a integer value from the keyboard a,b,c now we are applying if statement here, you can also solve this problem by using different statement. You can understand this example in an easy way by given below example.

a=10
b=20
c=30
First i check here
a>b && a>c if both conditions will true then a will be the greatest number else. Now we have only two numbers that are b and c.
Now we will check b>c here if b is greatest then the program will print b otherwise c will greatest.