QUOTE(fXp17 @ 2 Oct, 2007 - 04:40 AM)

I am trying to write a code where a user can enter 10 different numbers 1 through 200 and the greatest number and the smallest number are displayed after. A while structure must be used.
I am a beginner and don't even know where to start. I've created programs that use do simple equations. I've used if-else statements. Now I'm moving onto a while structure. Any help is appreciated to get me started.
**Try to make it easy to understand. I'm a quick learner but don't want to get lost and confused.

A while statement works like this:
CODE
while (this stuff is true)
{
do this stuff
}
Since you have a set number of inputs (10), you can do a counter (let's call it counter) that the while checks each time.
CODE
int counter = 0; // initialize counter as an integer equal to zero
int greatest = 0; // this variable will hold the biggest
int least = 201; // this variable will hold the smallest ( needs to be bigger than max number)
while (counter < 10) // while counter is less than 10 will run this ten times
{
get a number (called num) from the user
if the number is bigger than greatest then set greatest to the number
if the number is smaller than least then set least to the number
increment your counter by adding one to it
}
I left this as psuedocode so you'll learn it instead of me just giving you the answer. Does it make sense?
For the sake of simplicity, I left out checking to see if the user enters a number in the valid range of 1 - 200.
** EDIT: Fixed the While to while **
This post has been edited by Smarf: 2 Oct, 2007 - 06:46 AM