Do/ while help??

closed account (z6f9LyTq)
Write a C++ program that will calculate the average of each student, as well as the class average.

In a Loop, either a While, or Do/While you will input three test scores for each student. Output the student’s average, and then start with the next student.

I need help with this?? I only figured out how to do it with a FOR loop...

Create the code that produces the following output.

Input Section:

ENTER STUDENT #1’s - TEST SCORE NUMBER 1: ? 100

ENTER STUDENT #1’s - TEST SCORE NUMBER 2: ? 90

ENTER STUDENT #1’s - TEST SCORE NUMBER 3: ? 81

Output Section:
Test#1 Test#2 Test #3 Average

Student #1 100 90 81 90.33
Please, show your for-loop version.

The for loop has syntax:
1
2
3
for ( init ; cond ; increment ) {
  body
}


while loop could do the same:
1
2
3
4
5
init
while ( cond) {
  body
  increment
}
Last edited on
closed account (z6f9LyTq)
something like:

cout << "How many students are there?"
cin >> numstudents;

for (int testscore= 1; testscore<=numstudents; i++)
{
cout << "Enter test score: " << endl;
cin >> testscore;
}

i don't remember very well because i erased it (which wasn't wise) but it was something like that (and it worked very well, but I need to use a do/while loop as apart of the assignment)
Topic archived. No new replies allowed.