Print the highest and the lowest number

Please help me. I'm going to input number each 3 variables, the highest and the lowest should be printed.

Please guys help me ;[
Do you mean so, if I had the numbers 3, 6, 4. The number 6 would be printed as highest and 3 be printed as lowest?

If so, just check each variable with each other.

1
2
3
4
if ((number1 > number2) && (number1 > number3))
{
     std::cout << "Highest: " << number1;
}


Bit like that, might have to modify it a bit.
Something like that would be better I think:

1
2
3
4
5
6
7
int highest = number1; //just a guess, we will see if it is true
if(number2 > highest)
highest = number2; //it is not true, number2 is higher, readjust our guess
if(number3 > highest)
highest = number3; //it is not true, number3 is higher, readjust our guess

std::cout << "Highest: " << highest;


I think u can figure out the code for smallest by yourself
Topic archived. No new replies allowed.