Answer to Question #264108 in C++ for pica

Question #264108

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.


Sample Run:

Enter number of students: 2

Enter student 1 name: Jenny

Enter number of marks for Jenny: 2

Enter mark 1: 99

Enter mark 2: 88

Enter student 2 name: Kevin

Enter mark 1: 75

Enter mark 2: 76

Enter mark 3: 78

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

Student 1: Jenny

Marks: 99 88

Average for Jenny is: 93.5%

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

Student 2: Kevin

Marks: 75 76 78

Average for Kevin is: 76.3333%

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


1
Expert's answer
2021-11-10T14:51:16-0500
#include <iostream>
#include <cstring>
struct student{
int marks[5];
};
using namespace std;
int main()
{
    int number,i=0;
  cout<<"Enter number of students\t";
  cin>>number;
  for(i!=0;i<=number;i++){
   cout<<"Enter name of students\t";
  string name;
  cin>>name;
  cout<<"Enter number of marks:\n";
  int n;
  cin>>n;
  student stu[n];
int avarage=0;
  for(int i=0;i<n;i++){
    cout<<"Enter mark: "<<(i+1)<<": ";
    cin>>stu[n].marks[0];
   avarage+=(stu[i].marks[0]);
  }
   cout<<"Avarage is: "<<avarage/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