#include<iostream>
using namespace std;
class Student{
private:
int scores[5];
public:
Student(){
cout<<"Enter the student scores:\n";
for(int i=0; i<5; i++){
cout<<"Score "<<(i+1)<<":\n";
cin>>scores[i];
}
}
int calculateTotalScore(){
int sum = 0;
for(int i=0; i<5; i++){
sum += scores[i];
}
return sum;
}
};
int main(){
Student st;
cout<<"Total score is: "<<st.calculateTotalScore()<<endl;
}
Comments
Leave a comment