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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. C++
  3. Classes
  4. Classes and Objects
  5. Discussions

Classes and Objects

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • tigerleapgorge
    5 years ago+ 6 comments
    class Student{
        int scores[5];
        public:
        void input(){
            for(int i=0; i<5; i++){
                cin >> scores[i];
            }
        }
        int calculateTotalScore(){
            int total = 0;
            for(int i=0; i<5; i++){
                total += scores[i];
            }
            return total;
        }
    };
    
    39|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature