Sunday, 28 August 2011

find greatest number using conditional operator

Q. Using conditional operators write a program to find out in three Numbers which is greatest number?
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int n1,n2,n3;
 prinft("Enter Numbers n1, n2, n3 : ");
 scanf("%d"%d%d",n1,n2,n3);
 printf("Greatest=%d",n1>n2?n1>n3?x:z:y>z?y:z);
 getch();
 return 0;
}


       Output of above program : 
Enter Numbers n1, n2, n3 :10
20
30

Greatest=30

No comments:

Post a Comment