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
/******************************************************************************
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;
}
Comments
Leave a comment