Answer to Question #213823 in C++ for fawad khan

Question #213823

use a proper iterative structure to write a programin c++ that will read names and exam scores of students saving them in two different arrays. the class average is to be calculated and printed at the end of the report score can range from 0 to 100. the last record contains a blank name and a score 999 and is not be included in the calculations


1
Expert's answer
2021-07-05T06:51:34-0400
#include<iostream>
using namespace std;
struct stud{
	int score;
	char name[50];
};
int main(){
	int n;
	cout<<"Enter the number of the student"<<endl;
	cin>>n;
	struct stud names[n];
	struct stud scores[n];
	double sum = 0.0;
	for(int i=0; i<n; i++){
		cout<<"Enter the student name"<<endl;
		cin>>names[i].name;
		cout<<"Enter the score for "<<names[i].name <<endl;
		cin>>names[i].score;
		sum += names[i].score;
	}
	cout<<"The class average is\t"<<sum/n<<endl;
}

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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS