C++ based MCQs | Basic Level
Here are some basic-level multiple-choice questions (MCQs) on C++ programming along with their answers:
1. What does the following code snippet output?
a) Result: 2.5
b) Result: 2
c) Result: 2.0
d) Result: 2.5 (may vary)
Answer:
b) Result: 2
2.What is the correct way to declare and initialize a string variable in C++?
a) string name = "John";
b) char name[] = "John";
c) char* name = "John";
d) All of the above
Answer:
a) string name = "John";