Answer to Question #276721 in C++ for aribah

Question #276721

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


1
Expert's answer
2021-12-07T09:22:08-0500
#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";
		}	
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment