Tuesday, January 17, 2012

Greatest of two Numbers - Conditional Operator


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“enter the 2 numbers”);
scanf(%d%d”,&a,&b);
(a>b?printf(“a is greater”):printf(“b is greater”));
getch();
}

Output:
enter the two numbers
6
3
a is greater 

No comments:

Post a Comment