# Thread: My small programing problem

1. ## My small programing problem

Hello, Thank you for looking at this with me.

Im currently writing a basic basic program to sort of take a couple grade for test, quizzes etc, display the results for each student entered, Ive got this basis down. Now what i am having a hard time with is this:

1) the highest and lowest scores of the class.
2) the avg scores of the entire class.

i think for the high and low scores,i should use an if statement to determine whether or not the total points is higher or lower than the previous one and store the new value it if it is. But really i dont have the programming knowledge to do this.

For the average,i should just keep adding the total points every loop then divide it by the number of students, but im not sure how to store each score and have it add it all up in the end.

Any help would be greatly appreciated thank you!

2. Originally Posted by kordric
Hello, Thank you for looking at this with me.

Im currently writing a basic basic program to sort of take a couple grade for test, quizzes etc, display the results for each student entered, Ive got this basis down. Now what i am having a hard time with is this:

1) the highest and lowest scores of the class.
2) the avg scores of the entire class.

i think for the high and low scores,i should use an if statement to determine whether or not the total points is higher or lower than the previous one and store the new value it if it is. But really i dont have the programming knowledge to do this.

For the average,i should just keep adding the total points every loop then divide it by the number of students, but im not sure how to store each score and have it add it all up in the end.

Any help would be greatly appreciated thank you!
Code:
```int low_score, high_score;

//assign low_score and high_score to the very first student's score, then

if(current_score < low_score)
low_score = current_score;

if(current_score > high_score), etc.```
You don't need to store each score. Just keep a tally, and when the last score has been added to the tally, then divide by the number of scores.

Code:
```int tally, current_score, student_num;
tally = student_num = 0;

for (each student's score)
tally += current_score;
student_num++;```
That should get you started.

3. Thanks, this helps a lot. The avgs just adds the score to the previous amout then right?

4. What would got in between the for's ()? I having trouble with this part as well.

5. Originally Posted by kordric
What would got in between the for's ()? I having trouble with this part as well.
It's a loop. It typically goes for(initialize; check for; do what after each loop). Something like...

Code:
```for(int n = 0; n < 100; n++){
//stuff...
}```