-->
Showing posts with label nested if to get greatest value. Show all posts
Showing posts with label nested if to get greatest value. Show all posts

A program to get greatest value among three numbers using nested if.

//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();
}