Accept three number and display the greatest using conditional operator 

#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3,greater;
clrscr();
printf("enter three number:\n");
scanf("%d%d%d",&n1,&n2,&n3);
greater=(n1>n2)?((n1>n3)?n1:n3):((n2>n3)?n2:n3);//(using terneary operator)
printf("The largest number is :%d",greater);
getch();
}
OUTPUT:
enter the three number:
2
3
5
The largest number is:5
Translate »