Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class stu
{
    protected:
    int rno;
    public:
    void get_no(int a)
    {
        rno = a;
    }
    void put_no(void)
    {
    }
};
class test:public stu
{
    protected:
    float part1,part2;
    public:
    void get_mark(float x, float y)
    {
        part1 = x;
        part2 = y;
    }
    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 = part1 + part2 + score;
    put_no();
    put_marks();
    putscore();
    cout << "Total Score=" << total << "\n";
}
int main()
{
    result stu;
    stu.get_no(123);
    stu.get_mark(27.5, 33.0);
    stu.getscore(6.0);
    stu.display();
    return 0;
}

A. 66.5

B. 64.5

C. 62.5

D. 60.5

Answer: Option A


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it