Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class student
4.
{
5.
public:
6.
int rno , m1 , m2 ;
7.
void get()
8.
{
9.
rno = 15, m1 = 10, m2 = 10;
10.
}
11.
};
12.
class sports
13.
{
14.
public:
15.
int sm;
16.
void getsm()
17.
{
18.
sm = 10;
19.
}
20.
};
21.
class statement:public student,public sports
22.
{
23.
int tot,avg;
24.
public:
25.
void display()
26.
{
27.
tot = (m1 + m2 + sm);
28.
avg = tot / 3;
29.
cout
Options:
A .  3100
B .  3010
C .  2010
D .  1010
Answer: Option B

In this program, We are calculating the total and average marks of a student by using multiple inheritance.
Output:
$ g++ mul1.cpp
$ a.out
3010



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers