C program to find the Largest of Three Numbers using Conditional Operator..
PROGRAM:
#include<stdio.h>
int main()
{
int a,b,c,large;
printf("\n Enter Three Numbers:");
scanf("%d %d %d", &a , &b , &c);
large = (a>b && a>c ? a : b>c?b:c) ;
/* if a>b and a>c then large=a, else check whether b>c if
yes large=b else large=c */
printf("\n The Largest Number is: %d",large);
return(0);
}
Sample Output: ( using GNU GCC Compiler with Code Blocks IDE )
Enter Three Numbers: 5 7 6
The Largest Number is: 7
No comments:
Post a Comment