Find the maximum of three numbers using conditional operator (ternary operator) ?
#include<stdio.h>
#include<conio.h>
void main()
{
int num1=34,num2=27,num3=61,max;
clrscr();
max=num1 > num2 ? num1 > num3 ? num1: num3: num2 >num3 ? num2: num3;
printf("%d",max);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num1=34,num2=27,num3=61,max;
clrscr();
max=num1 > num2 ? num1 > num3 ? num1: num3: num2 >num3 ? num2: num3;
printf("%d",max);
getch();
}
No comments:
Post a Comment