Programming Examples
Write a program to find the largest number out of three numbers
Write a program to find the largest number out of three numbers. Read the numbers through the keyboard?
Solution
void main()
{
int x,y,z;
clrscr();
printf(“\nEnter Three Numbers x, y, z :”);
scanf(“%d %d %d”, &x,&y,&z);
printf(“\nLargest out of Three Numbers is :”);
if(x>y)
{
if(x>z)
printf(“x=%d\n”,x);
else
printf(“z=%d\n”,z);
}
else
{
if(z>y)
printf(“z=%d\n”,z);
else
printf(“y=%d\n”,y);
}
}
Output
OUTPUT:
Enter Three Numbers x, y, z : 10 20 30
Largest out of Three Numbers is :z=30