for my tutorial I have got to write a program that shows the difference between 2 ages and acts differently if one of the ages is over 100. i managed to get a partial result but why does it fall through the loop and still say too high even if both ages are under 100.
cout << "Enter an age under 100\n";
cin >> a;
cout <<"Enter another age under 100\n";
cin >> b;
(a < 100 && b < 100 && a < b)
cout <<"Age 1 was less than age 2\n";
elseif(a < 100 && b < 100 && b < a)
cout << "Age 2 was less than age 1\n";
else ( a > b || b > a && a > 100 || b > 100 );
cout << "To high\n";
Line 24: You have some problems in the statement.
1) You can't put a condition on an else clause.
2) The ; terminates the if/else statement. Line 26 is executed unconditionally.
3) You're ignoring operator precedence. http://www.cplusplus.com/doc/tutorial/operators/
The condition is going to be evaluated as: