So it usually helps me to write it out on paper. Normally after the 3rd sheet of paper I have a solution :P
Write a program that reads in five integers and determines and prints the largest and smallest integers in the group. |
This isn't hard at all, the trick seems to be in the part below.
Using the only input variables: largest, smallest, number. |
Another trick that's going to help you might be
1 2
|
int largest=0;
int smallest=2147483646;
|
Based on the instructions, I think you need to enter the numbers one at a time and determine if it's the largest or smallest when it's entered.
The loop will then ask for the next number.
You can use a while loop, I prefer a for loop.
1 2
|
if (number > largest)
largest = number;
|
After the above you will add
1 2
|
if (number < smallest)
smallest=number;
|
I'd also make the instructions a bit more clear, saying to enter 5 numbers one at a time and from 0 to something less than 2,147,483,647