Of the following table of three students having their marks in each of the subje
ID: 3831362 • Letter: O
Question
Of the following table of three students having their marks in each of the subjects, output the sum of marks obtained of each student. Write the algorithm and C++ code to store student name and course names in enum datatype and processing the array using enum variables (Marks 30)
Students: Jade, Joseph, Jared
Physics Grades: Jade - 88 Joseph - 95 Jared 76
Chemistry Grades: Jade - 97 Joseph - 58 Jared - 81
Biology Grades: Jade - 88 Joseph - 83 Jared - 79
Mathematics Grades: Jade - 77 Joseph - 71 Jared - 77
Explanation / Answer
#include<iostream>
#include<stdlib.h>
using namespace std;
enum Student{physics,chemistry,biology,mathematics};
//enum Jade{physics=88,chemistry=97,biology=88,mathematics=77};
//enum Joseph{physics=95,chemistry=58,biology=83,mathematics=71};
//enum Jared{physics=76,chemistry=81,biology=79,mathematics=77};
int main()
{
int arr[4],total,i;
for(i=0;i<3;i++)
{
cin>>arr[physics];
cin>>arr[chemistry];
cin>>arr[biology];
cin>>arr[mathematics];
total=arr[physics]+arr[chemistry]+arr[biology]+arr[mathematics];
cout<<total;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.