Answer to Question #263738 in C++ for pica

Question #263738

Write a program that prompts the user for number of students to process. The program will allow the user to enter the name of student and then it will ask for the number of marks for that student. The program will then prompt for each score and will calculate the average mark for each student. Make sure a structure ‘Student’ is defined. Use a function that prompts the user for the name of the student and number of test scores for that student. It stores the data into an array of type Student* and then returns that array. Use numTests[ ] array as an output parameter to store the number of tests for each student. This will then be passed to the display function. This function display marks and calculates the average for each student.


Sample Run:

Enter number of students: 1

Enter student 1 name: Jenny

Enter number of marks for Jenny: 2

Enter mark 1: 99

Enter mark 2: 88

=============================

Student 1: Jenny

Marks: 99 88

Average for Jenny is: 93.5%

=============================


1
Expert's answer
2021-11-10T09:36:39-0500
#include<iostream>
using namespace std;


struct Student{
	string name;
	int  marks[5];
};




int main(){
	cout<<"Enter the name of the student:\n";
	 string name;
	 cin>>name;
	 cout<<"Enter the number of marks:\n";
	 int n;
	 cin>>n;
	 Student stu[n];
	 int sum = 0 ;
	 for(int i=0; i<n; i++){
	 	cout<<"Enter mark "<<(i+1)<<": ";
	 	cin>>stu[i].marks[0];
	 	sum += stu[i].marks[0];
	 	
	 	
	 	
	 }
	 
	 cout<<"Average is: "<<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