Write a program to calculate students’ average test scores and their grades. Please take a look at the code.

closed account (DG6DjE8b)
//Use three arrays: a one-dimensional array to store the students’ names, a (parallel) two-dimensional array to store the test scores, and a parallel one dimensional array to store grades. Your program must contain at least the following functions: a function to read and store data into two arrays, a function to calculate the average test score and grade, and a function to output the results. Have your program also output the class average.

#include<iostream>
#include<cctype>
#include<string>
using namespace std;
const int numrows=10;
const int numcol=5;
int matrix [numrows][numcol];

void sumrows(int matrix[][numcol],int numrow);

int main()

{

const int Max=10;

string Name[Max]= {"Johnson","Aniston","Cooper","Gupta","Blair","Clark","Kennedy","Bronson","Sunny","Smith"};

for (int i=0; i < Max; i++)

//cout<<Name[i] <<endl; displays names

const int Rows=10;
const int Col=5;

int studentGrades[numrows][numcol]= {{85, 83, 77, 91, 76},

{80, 90, 95, 93, 48},

{78, 81, 11, 90, 73},
{23, 45, 96, 38, 59},
{60, 85, 45, 39, 67},

{77, 31, 52, 74, 83},

{93, 94, 89, 77, 97},

{79, 85, 28, 93, 82},

{85, 72, 49, 75, 63}};

sumrows(studentGrades, numrows);

cout<<endl;



return 0;

}

void sumRows(int matrix[][numcol],int numrows)

{

int row, col;
int sum;

for(row=0; row < numrows; row ++)

{

sum=0;

for(col =0; col < numcol; col++)

sum=sum+matrix[row][col];

cout<<"average =" <<(row+1)<<sum<<endl;

}

}
Last edited on
Topic archived. No new replies allowed.