-
I am at awe...
To the original poster:
If you input three numbers, one of those will be the largest. You start by setting the largest number as your first number. Then you compare the following input numbers with the current largest number, which will be the first number you input, to begin with.
If there aren't any numbers input that are larger than the first number, then what number is the largest number?
If there are any numbers that are larger than the first number, then your if statements will trigger and you will set them as the largest number.
Example:
in >> 4
largest = 4
in >> 3
is largest(4) bigger than 3?
no.
largest = 4
in >> 5
is largest(4) bigger than 5?
no.
largest = 5.
print largest(5)
-
After a few edits I was able to get thefinal version to work. Thank you guys!
Code:
large = number1 ; //First number will be the largest number to compare
if (large < number2) large = number2 ; //Then, compare large against number 2:
if (large < number3) large = number3 ; //Then, compare large against number 3:
cout << "The largest number is: " << large ;
cout << "\n";
cin.get ();
return 0;
}
-
Good job. A lot simpler, eh? :)