write a c++ program using nested loop that computes the average grade for multiple students each student has the same number of exam grade. prompt the user for the number of exam. when you finish the user prompt to see if there are morre students to process
#include<iostream>
using namespace std;
int main()
{
int numStud;
int numGrades;
double grade;
double sumGrades;
cout<<"Please, enter a number of students to process: ";
cin>>numStud;
cout<<"Enter a number of grades for students "<<": ";
cin>>numGrades;
for(int i=1;i<=numStud;i++)
{
sumGrades=0;
for(int j=1;j<=numGrades;j++)
{
cout<<"Enter a grade "<<j<<" for student "<<i<<" : ";
cin>>grade;
sumGrades+=grade;
}
cout<<"Average grade for student "<<i<<" is "
<<sumGrades/numGrades;
if(i==numStud)
{
cout<<"\nAll students processed";
}
else
{
cout<<"\nLeft "<<numStud-i<<" students for processing\n";
}
}
}
Comments
Leave a comment