Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class Cat
4.
{
5.
public:
6.
int age;
7.
int weight;
8.
};
9.
int main()
10.
{
11.
Cat f;
12.
f.age = 56;
13.
cout
Options:
A .  Gates is
B .  Gates is 56 years old
C .  Error
D .  None of the mentioned
Answer: Option B

In this program, We passed the value from main function to class and returning it to the main 

and then printing it.
Output:
$ g++ acc2.cpp
$ a.out
Gates is 56 years old



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers