Control flow statements determine the execution path of a program based on runtime conditions. In C++, decision-making relies primarily on conditional statements, including the single if branch, the if-else construct, the sequential else-if ladder, and nested conditional structures. These constructs evaluate expressions to boolean values (true or false), where any non-zero numeric value evaluates to true and zero evaluates to false. Mastery of C++ control flow requires an understanding of syntax rules, logical and relational operators, short-circuit evaluation behavior, variable scope within blocks, conditional ternary expressions (? :), and common pitfalls like single-statement scopes, assignment inside conditions (=), and dangling else ambiguities.
C++ Control Flow / If-Else MCQs Conditional Statements
1 min read
Correct Answer: a) It executes a block when the condition is true
Explanation:
An if statement runs its controlled statement only when its condition evaluates to true.
Correct Answer: b) if (x == 1) { }
Explanation:
C++ places the condition in parentheses and does not use the keyword then.
Correct Answer: c) When the if condition is false
Explanation:
The else clause provides code that runs when the if condition evaluates to false.
Correct Answer: d) Both else if and else
Explanation:
An if statement can be followed by zero or more else if branches and an optional else branch.
Correct Answer: a) A Boolean context
Explanation:
The condition is contextually converted to bool, so many scalar types can be used.
Correct Answer: b) The if block is skipped
Explanation:
Zero converts to false, so the if body is not executed.
Correct Answer: c) The if block executes
Explanation:
One converts to true, so the if body is executed.
Correct Answer: d) It is optional
Explanation:
An if statement may exist without an else clause.
Correct Answer: a) The remaining else if conditions are skipped
Explanation:
Only one branch in an if, else if, else chain is executed.
Correct Answer: b) One final else clause
Explanation:
A chain may contain multiple else if branches but only one final else.
Correct Answer: c) They are optional for a single controlled statement
Explanation:
If the body is a single statement, braces are optional, though often recommended.
Correct Answer: d) It is accessible only within that if block
Explanation:
Variables declared inside a block have block scope.
Correct Answer: a) It is attached to the nearest unmatched if
Explanation:
The else belongs to the closest if that does not already have an else.
Correct Answer: b) It assigns 5 to x and the condition is true
Explanation:
The single equals sign performs assignment, and the assignment expression yields 5, which converts to true.
Correct Answer: c) ==
Explanation:
The equality operator is written as two equal signs.
Correct Answer: d) !=
Explanation:
The inequality operator compares whether two values are not equal.
Correct Answer: a) <
Explanation:
The less-than operator compares two values and produces a Boolean result.
Correct Answer: b) &&
Explanation:
The double ampersand is the logical AND operator.
Correct Answer: c) ||
Explanation:
The double vertical bar is the logical OR operator.
Correct Answer: d) !
Explanation:
The exclamation mark negates a Boolean value.
Correct Answer: a) The right operand is not evaluated if the left operand is false
Explanation:
If the left side of && is false, the whole expression must be false, so the right side is skipped.
Correct Answer: b) The right operand is not evaluated if the left operand is true
Explanation:
If the left side of || is true, the whole expression is already true.
Correct Answer: c) False
Explanation:
The first comparison is true, but the second is false, so the AND expression is false.
Correct Answer: d) True
Explanation:
The first comparison is true, so the OR expression is true.
Correct Answer: a) condition ? expression1 : expression2
Explanation:
The ternary conditional operator selects the first expression when the condition is true and the second when it is false.
Correct Answer: b) The larger value
Explanation:
If a is greater than b, a is selected; otherwise, b is selected.
Correct Answer: c) Right to left
Explanation:
The conditional operator groups from right to left when nested.
Correct Answer: d) It is true because nonzero values convert to true
Explanation:
Any nonzero integral value converts to true in a Boolean context.
Correct Answer: a) if
Explanation:
The if statement is the basic decision-making statement in C++.
Correct Answer: b) cout executes always
Explanation:
The semicolon makes the if body an empty statement, so the following statement is not controlled by the if.
Correct Answer: c) else if (condition) { }
Explanation:
C++ uses the two keywords else and if together, with the condition in parentheses.
Correct Answer: d) elseif
Explanation:
C++ uses else if as two separate keywords, not elseif.
Correct Answer: a) An if statement inside another if statement
Explanation:
Nested if statements allow decisions to depend on multiple related conditions.
Correct Answer: b) Always
Explanation:
Only statement1 is controlled by the if statement; statement2 is outside the if body.
Correct Answer: c) Braces
Explanation:
Braces create a compound statement, allowing several statements to be controlled by one if.
Correct Answer: d) It checks conditions sequentially until one is true
Explanation:
The first true condition causes its branch to execute, and the rest are skipped.
Correct Answer: a) 1
Explanation:
The condition x == 3 is true, so the if branch prints 1.
Correct Answer: b) 2
Explanation:
The condition x > 5 is false, so the else branch prints 2.
Correct Answer: c) 2
Explanation:
Zero converts to false, so the else branch executes.
Correct Answer: d) 1
Explanation:
The assignment expression yields 7, which converts to true.
Correct Answer: a) !
Explanation:
Logical NOT has higher precedence than logical AND, logical OR, and assignment.
Correct Answer: b) ==
Explanation:
Equality comparison is evaluated before logical AND.
Correct Answer: c) When x is either 1 or 2
Explanation:
The OR operator makes the condition true if either comparison is true.
Correct Answer: d) When x is greater than 0 and less than 10
Explanation:
Both comparisons must be true because they are joined with AND.
Correct Answer: a) x != 5
Explanation:
The inequality operator != tests whether two values are different.
Correct Answer: b) x % 2 == 0
Explanation:
The modulo and equality operators combine to form a valid expression that evaluates to true or false.
Correct Answer: c) Whether x is even
Explanation:
An even integer has remainder 0 when divided by 2.
Correct Answer: d) true
Explanation:
Ten is less than twenty, so the comparison evaluates to true.
Correct Answer: a) 0
Explanation:
Zero is the integer value that converts to false.
Correct Answer: b) A null pointer
Explanation:
A null pointer converts to false, while a non-null pointer converts to true.
Correct Answer: c) Whether ptr is non-null
Explanation:
A pointer in a Boolean context is true when it is not null.
Correct Answer: d) It can contain multiple else if branches
Explanation:
C++ allows many else if branches before an optional final else.
Correct Answer: a) 1020
Explanation:
The if condition is true, so 10 is printed, and the second cout is outside the if, so 20 is also printed.
Correct Answer: b) 20
Explanation:
The if condition is false, so only the statement after the if executes.
Correct Answer: c) 20
Explanation:
The condition is false, so the else block executes.
Correct Answer: d) 10
Explanation:
The first condition is true, so its branch executes and the else if is skipped.
Correct Answer: a) 20
Explanation:
The first condition is false, but the else if condition is true.
Correct Answer: b) 30
Explanation:
Neither the if nor the else if condition is true, so the final else executes.
Correct Answer: c) 1
Explanation:
Both conditions are true, so the inner if branch prints 1.
Correct Answer: d) 2
Explanation:
The outer condition is true, but the inner condition is false, so the else attached to the inner if executes.
Correct Answer: a) Braces
Explanation:
Braces make the intended grouping of if and else explicit.
Correct Answer: b) The expression is contextually converted to bool
Explanation:
C++ allows many scalar expressions in if conditions by converting them to Boolean values.
Correct Answer: c) if (x > 0) cout << 1;
Explanation:
The condition must be in parentheses, and no colon or then keyword is used.
Correct Answer: d) if (x) then cout << x;
Explanation:
C++ does not use the keyword then in if statements.
Correct Answer: a) It exits a loop or switch
Explanation:
break terminates the nearest enclosing loop or switch statement.
Correct Answer: b) It skips to the next loop iteration
Explanation:
continue skips the remaining loop body and proceeds to the next iteration.
Correct Answer: c) It can handle integral constant case labels
Explanation:
switch works with integral or enumeration values and constant case labels.
Correct Answer: d) Execution falls through to the next case
Explanation:
Without break, control continues into subsequent case labels.
Correct Answer: a) double
Explanation:
switch requires an integral or enumeration type, not a floating-point type.
Correct Answer: b) case 5:
Explanation:
Case labels must be integral constant expressions.
Correct Answer: c) 1
Explanation:
Case 1 matches, prints 1, and break prevents fallthrough.
Correct Answer: d) 12
Explanation:
There is no break, so execution falls through from case 1 to case 2.
Correct Answer: a) It is optional
Explanation:
A switch statement may omit the default label.
Correct Answer: b) They must be constant expressions
Explanation:
Case labels must be unique integral constant expressions.
Correct Answer: c) do-while
Explanation:
A do-while loop checks its condition after executing the body.
Correct Answer: d) while
Explanation:
A while loop evaluates its condition before each iteration.
Correct Answer: a) 012
Explanation:
The loop prints 0, then 1, then 2, and stops before i becomes 3.
Correct Answer: b) No output
Explanation:
The condition is false initially, so the body never executes.
Correct Answer: c) 1
Explanation:
The do-while body executes once before the false condition is checked.
Correct Answer: d) while (true) { }
Explanation:
The condition is always true, so the loop never terminates by itself.
Correct Answer: a) switch
Explanation:
switch selects among multiple constant case labels.
Correct Answer: b) if-else
Explanation:
if-else can use relational expressions such as greater than and less than.
Correct Answer: c) The condition is false
Explanation:
The assignment expression yields 0, which converts to false.
Correct Answer: d) Braces
Explanation:
A block is written with an opening brace and a closing brace.
Correct Answer: a) The program continues after the if statement
Explanation:
An if statement without else simply skips its body when the condition is false.
Correct Answer: b) It can select one of two expressions
Explanation:
The ternary operator chooses between two expressions based on a condition.
Correct Answer: c) 1
Explanation:
The condition x > 5 is true, so the first value is selected.
Correct Answer: d) 2
Explanation:
The condition x > 5 is false, so the second value is selected.
Correct Answer: a) 10
Explanation:
The condition x > 3 is true, so 10 is selected.
Correct Answer: b) 20
Explanation:
The condition x > 3 is false, so 20 is selected.
Correct Answer: c) if (a > b) result = x; else result = y;
Explanation:
The ternary expression assigns x when the condition is true and y when it is false.
Correct Answer: d) It prints 1
Explanation:
Prefix increment changes x to 1, and 1 converts to true.
Correct Answer: a) 2
Explanation:
Postfix increment yields the old value 0, so the condition is false.
Correct Answer: b) 2
Explanation:
Prefix decrement changes x to 0, and 0 converts to false.
Correct Answer: c) 1
Explanation:
Postfix decrement yields the old value 1, so the condition is true.
Correct Answer: d) It may be legal but is often unintended
Explanation:
Assignment in a condition can compile, but programmers often meant to use equality comparison.
Correct Answer: a) x >= 1 && x <= 10
Explanation:
Both comparisons must be written separately and joined with AND.
Correct Answer: b) It does not test the range as intended
Explanation:
C++ evaluates 1 <= x first, producing a Boolean value, then compares that value with 10.
Correct Answer: c) It prints 1 regardless of the condition
Explanation:
The semicolon makes the if body empty, and the following block is independent.
Correct Answer: d) The order in which statements are executed
Explanation:
Control flow determines the sequence in which program statements run.
Related Posts

C++ STL MCQs (Standard Template Library)
The C++ Standard Template Library (STL) is a powerful set of template classes that provides general-purpose structures and functions for…
October 20, 2026By MCQs Generator

C++ Arrays / Lists - MCQs
Sequential data structures in C++ allow developers to store and manipulate contiguous collections of elements in memory. C++ provides multiple…
October 20, 2026By MCQs Generator
No Image
C++ Templates - MCQs
1. What does an if statement do in C++? a) It executes a block when the condition is true b)…
October 19, 2026By MCQs Generator








