Vidyalelo
C++ Programming · Q193

Classes and Objects in C++

Programming · C++ Programming · question 193

Q193

What will be the output of the following C++ code? #include using namespace std; class sample private: int var; public: void input() cout << var; void output() cout << "Variable entered is "; cout << var << " "; ; int main() sample object; object.input(); object.output(); object.var(); return 0;

A.
Enter an integer 5
Variable entered is 5
B.
Runtime error
C.
Error
Answer
D.
Enter an integer 7
Variable entered is 7

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board