Search This Blog

31 May, 2011

C Program of finding biggest of 3 numbers using ternary operator.


/* Biggest of 3 numbers using ternary operator - BIGTER.C */

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c, big;
clrscr();
a=1;
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

Meetme@