2. Find the largest number among 3 numbers with the ternary operator.
#include<stdio.h>
int main()
{
int num1,num2,num3,max;
printf("Enter three Numbers\n");
scanf("%d%d%d",&num1,&num2,&num3);
max=(num1>num2)? num1:num2;
max=(num3>max)? num3:max;
printf("The Greatest Number is %d",max);
return(0);
}
Output
Enter three Numbers
5
14
8
The Greatest Number is 14