32. WAP to find the largest number using Ternary Operator.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,max;
printf("Enter 3 numbers: ");
scanf("%d%d%d",&a,&b,&c);
max= a>b ? (a>c?a:c) : (b>c?b:c);
printf("\nThe largest number is %d",max);
getch();
}
Output:
Please have a look at the below lesson posted on my YouTube channel:
No comments:
Post a Comment