Method 1:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the three numbers :");
scanf("%d %d %d",&a,&b,&c);
if(a>b)
{
if(a>c)
printf("%d is greatest.",a);
else
printf("%d is greatest.",c);
else if(b>c)
printf("%d is greatest .",b);
else
printf("%d is greatest.");
getch();
}
Method 2:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the three numbers :");
scanf("%d %d %d",&a,&b,&c);
if(a>b?(a>c?printf("%d is greatest",a):printf("%d is greatest",c)):(b>c?printf("%d is greatest",b):printf("%d is greatest",c)))
getch();
}
Explanation:Method 2:
if(conidition?TRUE:FALSE)
we can place another condition at TRUE.
No comments:
Post a Comment