//Write a program to get greatest value among three numbers using nested if.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("enter numbers\n");
scanf("%d%d%d",&x,&y,&z);
if(x>y)
{
if(x>z)
{
printf("x is greatest");
}
else
{
printf("z is greatest\n");
}
}
else
{
if(y>x)
{
if(y>z)
{
printf("y is greatest");
}
else
{
printf(" z is greatest");
}
}
else
{
printf("x is greatest");
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("enter numbers\n");
scanf("%d%d%d",&x,&y,&z);
if(x>y)
{
if(x>z)
{
printf("x is greatest");
}
else
{
printf("z is greatest\n");
}
}
else
{
if(y>x)
{
if(y>z)
{
printf("y is greatest");
}
else
{
printf(" z is greatest");
}
}
else
{
printf("x is greatest");
}
}
getch();
}
No comments:
Post a Comment