Answer to Question #222597 in C++ for dunga

Question #222597

Write a C++ program to calculate the total marks of each student of a class. This class takes the

following subjects Physics, Chemistry and Mathematics. Your program shall be able to calculate the

total marks for each student, this is the sum of marks from the three subjects


1
Expert's answer
2021-08-02T15:55:48-0400
/******************************************************************************
Write a C++ program to calculate the total marks of each student of a class. This class takes the


following subjects Physics, Chemistry and Mathematics. Your program shall be able to calculate the


total marks for each student, this is the sum of marks from the three subjects


*******************************************************************************/


#include <iostream>


using namespace std;


int main()
{
    cout<<"\nEnter number of students: ";
    int n;
    cin>>n;
    int total_marks[n];
    int sum;
    for(int i=0;i<n;i++){
        sum=0;
        cout<<"\nEnter marks for Physics, Mathematics and Chemistry for student "<<i+1<<": \n";
        int phyc,math,chem;
        cin>>phyc;
        cin>>math;
        cin>>chem;
        sum=(phyc+math+chem);
        total_marks[i]=sum;


    }
    cout<<"Total marks for each student:\n";
    for(int i=0;i<n;i++){
        cout<<"\nStudent "<<i+1<<" : "<<total_marks[i];
    }
    return 0;
}

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