// compare3.cpp
//
// Finds the maximum of 3 floating-point numbers
// entered by the user.
//
// This program is not correct! Can you find the error?
#include <iostream>
using namespace std;
const int NUMBER_OF_NUMBERS = 3;
int main()
{
// Announce purpose of program:
cout << "This program will find the largest of "
<< NUMBER_OF_NUMBERS
<< " floating-point numbers." << endl;
// Input the numbers, and check their validity:
cout << "Enter " << NUMBER_OF_NUMBERS
<< " numbers separated by spaces:>";
float number1;
float number2;
float number3;
cin >> number1 >> number2 >> number3;
// Find the largest of the first two numbers:
float largest;
if ( number1 > number2 )
largest = number1;
if ( number1 < number2 )
largest = number2;
// Find the largest of all three numbers:
// by comparing the third number to the
// largest of the first two:
if ( number3 > largest )
largest = number3;
// Output the result:
cout << "The largest of " << number1
<< ", " << number2
<< ", and " << number3
<< " is " << largest << "." << endl;
return 0;
} // function main