Sunday, 28 August 2011

comparison of three numbers

Q. Write a program to compare three numbers which is greatest,middle and lowest?

Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z;
 printf("Enter values of x, y and z : ");
 scnaf("%d%d%d",&x,&y,&z);
 if(x>=y && x>=z)
   printf("\nx=%d is greatest",a);
 else if(y>=z)
   printf("\ny=%d is greatest",y);
 else
   printf("\nz=%d is greatest",z);
 getch();
 return 0;
}

      Output of above program :
Enter values of x,y and z : 30
20
100

z=100 is greatest

No comments:

Post a Comment