#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// Declare variables
int SIZE;
int testScores[SIZE];
int numStudents;
int stuCount;
int testCount;
double testTotal;
double average;
int sum;
// This is the work done in the housekeeping() function
// Get user input to control loop
cout << "Enter number of students: ";
cin >> numStudents;
SIZE = numStudents;
// Initialize accumulator variable to 0
testTotal = 0;
// This is the work done in the detailLoop() function
// Loop for each student
stuCount = 0;
cout << "How many tests will each student be taking?";
cin >> testCount;
//User enters test scores of amount of students taking the test
while (stuCount <= numStudents)
{
cout << "Enter the test score for " numStudents " students";
cin >> testScores[];
stuCount++;
}
//Gets the sum of the array
for (int a=0; a=<numStudents; a++)
{
testTotal+=testScore[a];
}
// Calculate average test score
average = testTotal / stuCount;
// Output number of students and average test score
cout << "Number of Students: " << numStudents << endl;
cout << "Average Test Score: " << average << endl;
return 0;
}
Because "SIZE" needs to be a constant as in constexprint SIZE{ 10 }; or constint SIZE{ 10 };. The first is a newer form. The capital letters let you know that it is defined as a constant and can not be changed. This means line 23 will not work.
When you define an array the size of the array needs to be a constant value. This could be a variable defined as a constant or a number like 10. At compile time the compiler needs to know how much space to set aside for the array. That is why it needs to be a fixed number. If you need an array based on a variable then you will need to create a dynamic array.
I will have to check into the rest of the program in a bit.
You should compile the program before you post the code. This way if there are any errors that you do not understand you can add them to the message.
Once I made some changes I found more problems.
The while loop is not doing what it should. It could be made to work, but a for loop or loops would work better. As it is it is not working to collect the test scores from all the students.
Variables like "testTotal" and "stuCount" lines 26 and 31. These variables can be initialized when they are defined unless there is a need to do it later.
You need to re think what you need to do and make the program do it.