# Find maximum number (while loop)

• 10-16-2006
katherene
alright so you guys seemed like the people to ask.

my teacher asked me to basically do this:

take a bunch of numbers and find the highest, i have to use a while loop to get all the numbers. I have no clue how that would look in code and my book is a piece of ........ so it doesn't help.

the actual promt is : a teacher has a set of student grades and wants to know the highest grade in the class regardless of the number of students in the class. develope a program to accomplish this

a pseudocode or agorethm is helpful
• 10-16-2006
DougDbug
Welcome to the forum, katherene

(Next time, click New Thread to start a new topic.)

It depends on how the grades are given to you. They will probably be given in an array, or from a disk file.

The general idea is to initialize Max (and Min) to the first value.

```Max = Grade[0];  // Initialize Max and Min before entering the loop. Min = Grade[0];  // Max and Min are the same until you check the next grade in the list```
```if( Grade[1] > Max)  // Update Max if needed     {     Max = Grade[1];     } if( Grade[1] < Min)  // Update Min if needed     {     Min = Grade[1];     }```