7. WRITE A C PROGRAM USING CONDITIONAL OPERATOR TO FIND GREATEST OF TWO NUMBERS

/*C program using conditional operator to find greatest of two numbers*/

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z;
clrscr();
printf(" Enter value of x:");
scanf("%d",&x);
printf("\n Enter value of y:");
scanf("%d",&y);
z=(x>y)?x:y;
printf("\n %d is greater number",z);
getch();
}

output

Enter value of x:30
Enter value of y:50
50 is greater number

Comments