To find minimum of three numbers using ternary (conditional) operator
Appearance
/* To find minimum of three numbers using ternary (conditional) operator*/
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c,temp,min;
clrscr();
printf ("\n\n Enter three nos. one after the other: ");
scanf ("%d%d%d", &a, &b, &c);
temp = (a<b)? a:b;
min = (c<temp)? c:temp;
printf ("\n\n The Minimum of the three is: %d", min);
getch();
}
/* Output:
Enter three nos. one after the other: 2 5 9
The Minimum of the three is: 2
*/