In the output, there was an error when I attempted to display it. The output is displayed without any errors, but the total marks and percentages are not displayed. I would appreciate if anyone could provide an explanation.
- create a class student that stores roll_no,name.
- create a class test that stores marks obtained in five subjects.
- class result derived from student and test contains the total marks and percentage obtained in the test.
- input and display information of a student.
#include <iostream>
using namespace std;
class student {
    int roll_no;
    string name;
public:
    void studentdata()
    {
        cout << "\n ENTER STUDENT NAME:";
        cin >> name;
        cout << "\nENTER ROLL NUMBER:";
        cin >> roll_no;
    }
};
class test {
    int i;
    // int marks[5{}];
public:
    int marks[5];
    void getmarks()
    {
        cout << "\nENTER MARKS OF EACH SUBJECT:";
        for (i = 0; i < 5; i++) {
            cout << "\n subject " << (i + 1) << " :";
            cin >> marks[i];
        }
    }
};
class result : public student, public test {
    int i;
    float totalmarks = 0;
    float percent;
public:
    void percentage()
    {
        // int total_marks=0;
        for (i = 0; i < 5; i++) {
            totalmarks += totalmarks + marks[i];
        }
        cout << " \n TOTAL MARKS OUT OF 500 IS:" << totalmarks;
        percent = (totalmarks * 100) / 500;
        cout << " \n \nPERCENTAGE OBTAINED IN THE TEST:" << percent << " %";
    }
};
int main()
{
    student s;
    test t;
    result r;
    s.studentdata();
    t.getmarks();
    r.percentage();
    return 0;
}
 
     
    