Thursday 12 March 2015

Biggest of 3 numbers using ternary operator Using C


# include <stdio.h>
# include <conio.h>
void main()
{
int a, b, c, big ;
clrscr() ;
printf("Enter three numbers : ") ;
scanf("%d %d %d", &a, &b, &c) ;
big = a > b ? (a > c ? a : c) : (b > c ? b : c) ;
printf("\nThe biggest number is : %d", big) ;
getch() ;
}


RUN 1 :
~~~~~~~
Enter three numbers : 10 20 30
The biggest number is : 30
RUN 2 :
~~~~~~~
Enter three numbers : 20 30 10
The biggest number is : 30
RUN 3 :
~~~~~~~
Enter three numbers : 30 10 20
The biggest number is : 30

No comments:

Post a Comment