C Program to Find Greatest of Three Numbers using Nested If.
The following example shows, how to find greatest of three numbers using Nested If in C Program.
Example : pgm.c
#include<stdio.h> int main(){ int a,b,c; printf("\nEnter Three Numbers : "); scanf("%d%d%d",&a,&b,&c);//100 98 105 if(a>b){ if(a>c){ printf("\n%d is greatest number ",a); }else{ printf("\n%d is greatest number ",c); } }else if(b>a){ if(b>c){ printf("\n%d is greatest number ",b); }else{ printf("\n%d is greatest number ",c); } }else{ printf("\n%d is greatest number ",a); } return 0; }
Output:
Enter Three Numbers : 25
36
20
36 is greatest number
36
20
36 is greatest number