We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
class Student
{
private:
int scores[5];
public:
void input()
{
int i = 0;
for(i=0;i<5;i++){
cin >> scores[i];
}
}
int calculateTotalScore()
{
int sum = 0;
int i = 0;
for(i=0;i<5;i++)
{
sum = sum + scores[i];
}
return sum;
}
};
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Classes and Objects
You are viewing a single comment's thread. Return to all comments →
class Student { private: int scores[5]; public: void input() { int i = 0; for(i=0;i<5;i++){ cin >> scores[i]; } } int calculateTotalScore() { int sum = 0; int i = 0; for(i=0;i<5;i++) { sum = sum + scores[i]; } return sum; }
};