Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class stu
4.
{
5.
protected:
6.
int rno;
7.
public:
8.
void get_no(int a)
9.
{
10.
rno = a;
11.
}
12.
void put_no(void)
13.
{
14.
}
15.
};
16.
class test:public stu
17.
{
18.
protected:
19.
float part1,part2;
20.
public:
21.
void get_mark(float x, float y)
22.
{
23.
part1 = x;
24.
part2 = y;
25.
}
26.
void put_marks()
27.
{
28.
}
29.
};
30.
class sports
31.
{
32.
protected:
33.
float score;
34.
public:
35.
void getscore(float s)
36.
{
37.
score = s;
38.
}
39.
void putscore(void)
40.
{
41.
}
42.
};
43.
class result: public test, public sports
44.
{
45.
float total;
46.
public:
47.
void display(void);
48.
};
49.
void result::display(void)
50.
{
51.
total = part1 + part2 + score;
52.
put_no();
53.
put_marks();
54.
putscore();
55.
cout
Options:
A .  66.5
B .  64.5
C .  62.5
D .  60.5
Answer: Option A

In this program, We are passing the values by using different
methods and totaling the marks to get the result.
Output:
$ g++ class.cpp
$ a.out
Total Score=66.5



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers