Search Your C Program

Thursday, 26 January 2012

Greater from Two Numbers using Conditional Operator

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


NOTE:= The conditional operators (?,:)  are also called "Ternary Operators" because
                they operate on three expression. The general form of conditional operator is
                 expr1 ? expr2 : expr3.






                       

No comments:

Post a Comment