Explanation:
The variable var starts at 0.
The while (var < 10) loop prints 0 1 2 3 4 5 6 7 8 9 with spaces.
When var reaches 10, the loop stops.
After the loop, cout << var; prints 10.
Final output:
Explanation:
int Demo::count = 0; initializes the static variable count to 0.
Demo var1; → constructor is called once → count = 1.
Demo var2[5]; → constructor is called 5 times (for each element in the array) → count = 6.
Since count is static, it is shared among all objects.
Finally, cout << var1.count; prints 6.
? Correct answer: (A) 6 ✅
Explanation:
print() is declared as void print().
In main(), the statement var = print(); tries to assign the return value of print() to an int variable.
But since print() has no return value (void), this causes a compile-time error.
Hence, the program does not compile.
Explanation:
Initially var = 2.
First iteration: prints 2, then var-- makes var = 1.
Second iteration: prints 1, then var-- makes var = 0.
Third iteration: prints 0, then var-- makes var = -1. Condition fails and loop exits.
So output is:
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.