-
What is the output of this program?
#include <iostream>
using namespace std;
class student
{
protected:
int Rollno;
public:
void get_Rollno(int num)
{
Rollno = num;
}
void put_Rollno(void)
{
}
};
class test:public student
{
protected:
float Subject1,Subject2;
public:
void get_mark(float num1, float num2)
{
Subject1 = num1;
Subject2 = num2;
}
void put_marks()
{
}
};
class sports
{
protected:
float score;
public:
void getscore(float s)
{
score = s;
}
void putscore(void)
{
}
};
class result: public test, public sports
{
float total;
public:
void display(void);
};
void result::display(void)
{
total = Subject1 + Subject2 + score;
put_Rollno();
put_marks();
putscore();
cout << "Total Score = " << total << "\n";
}
int main()
{
result student;
student.get_Rollno(101);
student.get_mark(50.25, 42.52);
student.getscore(7.0);
student.display();
return 0;
}
-
- 50.25
- 42.52
- 99.77
- Compilation Error
- None of these
Correct Option: C
In this program, We are passing the values by using different
methods and totaling the marks to get the result.