0

Hello all,

I'm suppose to write a program that asks the user to input five numbers. Out of those five numbers, the program is suppose to select the maximum value. I attempted to do it with "else-if" statements as can be seen in the following code. I was hoping there was a function included in the math.h or stdlib.h header files that could do this for me. However, there doesn't seem to be one. Here is what I have:

```
int main()
{
float first_number;
float second_number;
float third_number;
float fourth_number;
float fifth_number;
printf("Please input five numbers: ");
scanf("%f%f%f%f%f", &first_number, &second_number, &third_number, &fourth_number, &fifth_number);
if (first_number > second_number && first_number > third_number &&
first_number > fourth_number && first_number > fifth_number)
{
printf("The largest value is %f.", first_number);
}
else if (second_number > first_number && second_number > third_number &&
second_number > fourth_number && second_number > fifth_number)
{
printf("The largest value is %f.", second_number);
}
else if (third_number > first_number && third_number > second_number &&
third_number > fourth_number && third_number > fifth_number)
{
printf("The largetst value is %f.", third_number);
}
else if (fourth_number > first_number && fourth_number > second_number &&
fourth_number > third_number && fourth_number > first_number)
{
printf"The largest value is %f.", fourth_number);
}
else (fifth_number > first_number && fifth_number > second_number &&
fifth_number > third_number && fifth_number > fourth_number)
{
printf("The largest value is %f.", fifth_number);
}
return 0;
```

Am I on the right track or totally off the mark? I am to stick to using "if-else", switch, or "else-if" statements.

Noble