I need help!!!

Please I need help for my computer class. I need a program that will prompt the user to enter number of students, then the number of quizzes, then the quiz scores. After that, the program will output the average of the quizzes of each student. So far I have this:

#include <iostream>
#include<cstdlib>
using namespace std;

int main()
{
int quiz = 0;
int score[quiz];
int NumofQuiz = 0;
int a;
double total = 0;
double average;
NumofQuiz = 0;
cout<<"How many scores are there? ";
cin >> quiz;
cout<<"Enter a score: ";
cin >> score[NumofQuiz];
int minimum = score[NumofQuiz]; // initialize to first score.
int maximum = score[NumofQuiz]; // initialize to first score.
while(NumofQuiz < quiz && score[NumofQuiz])
{
total += score[NumofQuiz];
++NumofQuiz;
if(NumofQuiz < quiz)
{
cout<<"Enter a score: ";
cin>>score[NumofQuiz];
if (score[NumofQuiz] < minimum)
{
minimum = score[NumofQuiz];
}
if (score[NumofQuiz] > maximum)
{
maximum = score[NumofQuiz];
}
}
}
cout<< "The entered test scores are: ";

for (a = 0; a < NumofQuiz; ++a)
cout<<score[a]<<" ";
average = total / NumofQuiz;
cout<<endl<<"The average test score is "<<average<<endl;

system ("PAUSE");
}
The only thing I need is to prompt the user to enter the number of students and that the program will do repeat this as many times as the number of students.
Last edited on
And...you need help with?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include<cstdlib>
using namespace std;

int main()
{
int quiz = 0;
int score[quiz];
int NumofQuiz = 0;
int a;
double total = 0;
double average;
NumofQuiz = 0;
cout<<"How many scores are there? ";
cin >> quiz;

//Do while loop based on quizz. possibly do{.......quizz--}while(quiz!=0)?

cout<<"Enter a score: ";
cin >> score[NumofQuiz];
int minimum = score[NumofQuiz]; // initialize to first score.
int maximum = score[NumofQuiz]; // initialize to first score.
while(NumofQuiz < quiz && score[NumofQuiz])
{
total += score[NumofQuiz];
++NumofQuiz;
if(NumofQuiz < quiz)
{
cout<<"Enter a score: ";
cin>>score[NumofQuiz];
if (score[NumofQuiz] < minimum)
{
minimum = score[NumofQuiz];
}
if (score[NumofQuiz] > maximum)
{
maximum = score[NumofQuiz];
}
}
}
cout<< "The entered test scores are: ";

for (a = 0; a < NumofQuiz; ++a)
cout<<score[a]<<" ";
average = total / NumofQuiz;
cout<<endl<<"The average test score is "<<average<<endl;

system ("PAUSE");
}




Try looking up control statements. A while loop with a decrement based on number of students would most likely do what you're trying to accomplish.



Last edited on
Topic archived. No new replies allowed.