Write a void function to find the average score on each test and store in an array testAvgs.
Write a void function to print the average score for each student, i.e. print the contents of the array studentAvgs. The output will be well formatted and accompanied with appropriate messages.
Write a void function to print the average score on each test, i.e. print the contents of the array testAvgs. The output will be well formatted and accompanied with appropriate messages.
Add the following declaration for the array studentsPassing in the function main.
bool studentsPassing[MAX_STUDENTS];
Write a function that initializes all components of the array studentsPassing to false. The array studentsPassing is a parameter.
void Initialize(bool studentsPassing[],int numberOfStudents)
Write a function that has studentsPassing , studentAvgs, and numberOfStudents as parameters.
Set the components
of passing to true whenever the corresponding value in studentAvgs is greater than or equal to 50.0
Write a function that has studentsPassing as parameter and print the number of students who passed, i.e. count and print the number of components in studentsPassing that are true. It will also print which students passed. Display meaningful messages.
Write a function that has studentAvgs and numberOfStudents as parameters, and determine the highest average score of the class. This value and the student number with this value will be formatted and printed with an appropriate message. Complete the program with the functions and the appropriate function calls.
Use the following code and add the above functions in the code, make sure you add all the functions in the program:
#include
using namespace std;
const int MAX_STUDENTS = 30;
const int MAX_TESTS = 10;
//function to read each student scores from user
void ReadScore(double scores[][MAX_TESTS], int& numberOfStudents, int& numberOfTests)
{
int student, test;
cout < "enter="" number="" of="" students:="">
cin >> numberOfStudents;
cout < "number="" of="" tests:="">
cin >> numberOfTests;
for (student = 0; student < numberofstudents;="">
{
cout < "enter="" "="">< numberoftests="">< "="" scores="" of="" student="" "="">< student="" +="" 1="">< ":="" "=""><>
for (test = 0; test < numberoftests;="">
{
cin >> scores[student][test];}}}
void PrintScore(double scores[][MAX_TESTS], int numberOfStudents, int numberOfTests)
{
int student, test;
for (student = 0; student < numberofstudents;="">
{
cout < "the="" test="" score="" for="" student="" "="">< student="" +="" 1="">< "="" are:="" "=""><>
for (test = 0; test < numberoftests;="">
{
cout < scores[student][test]="">< "="">
cout < endl;="" }}void="" averagescore(double="" scores[][max_tests],="" int="" numberofstudents,="" int="" numberoftests,="" double="">
{
double total;
int student, test;
for (student = 0; student < numberofstudents;="">
{
total = 0;
for (test = 0; test < numberoftests;="">
{
total += scores[student][test];
}
studentAverage[student] = total / numberOfTests; }}
void PrintAverageScore(int numberOfStudents, double studentAverage[])
{
int student;
for (student = 0; student < numberofstudents;="">
{
cout < "average="" score="" of="" student="" "="">< student="" +="" 1="">< "="" is:="" "="">< studentaverage[student]=""><>
//function to initilize passing array for each student to false
void Initialize(bool passing[MAX_STUDENTS], int numberOfStudents)
{
int student;
for (student = 0; student < numberofstudents;="">
{
passing[student] = false;}
//function to decide and set the passing arry
//if ith student is passsed then passing[i]=true
void SetPassing(bool passing[MAX_STUDENTS], double studentAverage[], int numberOfStudents)
{
int student;
for (student = 0; student < numberofstudents;="">
{
if (studentAverage[student] >= 50)
passing[student] = true;}}
//function to print number of student passed in exam
void PrintPassing(bool passing[MAX_STUDENTS], int numberOfStudents)
{
int count = 0, student;
for (student = 0; student < numberofstudents;="">
{
if (passing[student] == true)
count++;
}
cout < "number="" of="" students="" passed=" << count << endl;
}
//function to print the srudent having highest average
void PrintHighestAverageScore(int numberOfStudents, double studentAverage[])
{
int highest_index = 0, student;
for (student = 0; student < numberOfStudents; student++)
{
if (studentAverage[highest_index] < studentAverage[student])
highest_index = student;
}
cout << " the="" student="" with="" highest="" average=" << highest_index + 1;
}
//main function
int main()
{
double scores[MAX_STUDENTS][MAX_TESTS];
double studentAverage[MAX_STUDENTS];
int numberOfStudents;
int numberOfTests;
bool passing[MAX_STUDENTS];
cout << " welcome="" to="" student="" evalution="" system"=""><>
ReadScore(scores, numberOfStudents, numberOfTests);
AverageScore(scores, numberOfStudents, numberOfTests, studentAverage);
PrintAverageScore(numberOfStudents, studentAverage);
Initialize(passing, numberOfStudents);
PrintScore(scores, numberOfStudents, numberOfTests);
SetPassing(passing, studentAverage, numberOfStudents);
PrintPassing(passing, numberOfStudents);
PrintHighestAverageScore(numberOfStudents, studentAverage);
}