Wednesday, February 16, 2011

Decision Making and Branching

This program selects and prints the largest of the three numbers using nested if....else statements.

#include <stdio.h>
void main()
{
float A, B, C;
printf("Enter three values\n");
scanf("%f %f %f", &A, &B, &C);
printf("\nLargest value is  ");
if (A>B)
{
if (A>C)
printf("%f\n", A);
else
printf("%f\n", C);
}
else
{
if (C>B)
printf("%f\n", C);
else
printf("%f\n", B);
}
getch();
}

No comments:

Post a Comment