C program to find largest among three numbers using ternary operator( ?: ).

#include<stdio.h>
#include<conio.h>
int main(){
float a, b, c;
clrscr();
printf("Enter three numbers: ");
scanf("%f %f %f", &a, &b, &c);
(a>b)? if(a>c)? printf("Largest number = %.2f",a): printf("Largest number = %.2f",c): if(b>c) printf("Largest number = %.2f",b): printf("Largest number = %.2f",c);
getch();
return 1;
}

No comments:

Post a Comment