Answer & Solution
Answer: Option A
Solution:
Explanation:
Let's break down this C++ code step by step:
1. Variable Initialization:
int x = 10;
This line creates an integer variable named 'x' and assigns it the value 10.
2. `if` Statement:
if (x < 5)
This checks if the value of 'x' (which is 10) is less than 5. Since 10 is not less than 5, this condition is false.
3. `else if` Statement:
else if (x == 5)
Because the first `if` condition was false, the program moves to the `else if` condition. This checks if 'x' is equal to 5. Since 10 is not equal to 5, this condition is also false.
4. `else` Statement:
else cout << "More";
Since both the `if` and `else if` conditions were false, the program executes the code within the `else` block. This line prints "More" to the console.
Therefore, the output of the code will be "More".
Correct Answer: A) More