C++ Control Flow / If-Else MCQs Conditional Statements

1 min read

1. What does an if statement do in C++?

a) It executes a block when the condition is true
b) It executes a block when the condition is false
c) It cannot be used with else
d) It must always use braces
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.

2. Which is the correct basic syntax of an if statement in C++?

a) if x == 1 then { }
b) if (x == 1) { }
c) if x == 1 { }
d) if {x == 1}
Correct Answer: b) if (x == 1) { }
Explanation:
C++ places the condition in parentheses and does not use the keyword then.

3. When does the else part of an if statement execute?

a) When the if condition is true
b) When the program ends
c) When the if condition is false
d) Whenever a loop executes
Correct Answer: c) When the if condition is false
Explanation:
The else clause provides code that runs when the if condition evaluates to false.

4. Which of the following can directly follow an if statement in C++?

a) Only else
b) Only else if
c) Only switch
d) Both else if and else
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.

5. In C++, the condition inside an if statement is evaluated in which context?

a) A Boolean context
b) An integer-only context
c) A string-only context
d) A pointer-only context
Correct Answer: a) A Boolean context
Explanation:
The condition is contextually converted to bool, so many scalar types can be used.

6. What happens when the condition is if (0)?

a) The if block executes
b) The if block is skipped
c) A compile error occurs
d) An infinite loop occurs
Correct Answer: b) The if block is skipped
Explanation:
Zero converts to false, so the if body is not executed.

7. What happens when the condition is if (1)?

a) The if block is skipped
b) A compile error occurs
c) The if block executes
d) The block executes only inside a loop
Correct Answer: c) The if block executes
Explanation:
One converts to true, so the if body is executed.

8. Which statement is true about the else part of an if statement?

a) It is required for every if statement
b) It is required when using else if
c) It is required for compilation
d) It is optional
Correct Answer: d) It is optional
Explanation:
An if statement may exist without an else clause.

9. In an if, else if, else chain, what happens after the first true condition is found?

a) The remaining else if conditions are skipped
b) All remaining conditions are still checked
c) The final else always executes
d) A compile error occurs
Correct Answer: a) The remaining else if conditions are skipped
Explanation:
Only one branch in an if, else if, else chain is executed.

10. How many final else clauses can be associated with one if, else if chain?

a) Unlimited final else clauses
b) One final else clause
c) Two final else clauses
d) No final else clause
Correct Answer: b) One final else clause
Explanation:
A chain may contain multiple else if branches but only one final else.

11. When are braces required around the body of an if statement?

a) Always
b) Only with else
c) They are optional for a single controlled statement
d) Only inside functions
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.

12. What is true about a variable declared inside an if block?

a) It becomes global
b) It is accessible after the if block ends
c) It cannot be an integer
d) It is accessible only within that if block
Correct Answer: d) It is accessible only within that if block
Explanation:
Variables declared inside a block have block scope.

13. In C++, how is a dangling else resolved?

a) It is attached to the nearest unmatched if
b) It is attached to the outermost if
c) It is chosen by the compiler arbitrarily
d) It is not allowed in nested code
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.

14. If x is an int, what does if (x = 5) do?

a) It compares x with 5
b) It assigns 5 to x and the condition is true
c) It causes a syntax error
d) It assigns false to x
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.

15. Which operator checks equality in C++?

a) =
b) :=
c) ==
d) !=
Correct Answer: c) ==
Explanation:
The equality operator is written as two equal signs.

16. Which operator checks inequality in C++?

a) ==
b) =
c) <=
d) !=
Correct Answer: d) !=
Explanation:
The inequality operator compares whether two values are not equal.

17. Which of the following is a relational operator?

a) <
b) &&
c) !
d) =
Correct Answer: a) <
Explanation:
The less-than operator compares two values and produces a Boolean result.

18. Which operator represents logical AND in C++?

a) &
b) &&
c) AND
d) and&
Correct Answer: b) &&
Explanation:
The double ampersand is the logical AND operator.

19. Which operator represents logical OR in C++?

a) |
b) OR
c) ||
d) !
Correct Answer: c) ||
Explanation:
The double vertical bar is the logical OR operator.

20. Which operator represents logical NOT in C++?

a) ~
b) ^
c) !=
d) !
Correct Answer: d) !
Explanation:
The exclamation mark negates a Boolean value.

21. What does short-circuit evaluation mean for the && operator?

a) The right operand is not evaluated if the left operand is false
b) The right operand is always evaluated
c) The left operand is not evaluated
d) Both operands are always evaluated
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.

22. What does short-circuit evaluation mean for the || operator?

a) The left operand is never evaluated
b) The right operand is not evaluated if the left operand is true
c) The right operand is not evaluated if the left operand is false
d) Both operands are always evaluated
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.

23. What is the result of the condition if (5 > 3 && 2 > 4)?

a) True
b) Syntax error
c) False
d) Compile error
Correct Answer: c) False
Explanation:
The first comparison is true, but the second is false, so the AND expression is false.

24. What is the result of the condition if (5 > 3 || 2 > 4)?

a) False
b) Compile error
c) It is skipped
d) True
Correct Answer: d) True
Explanation:
The first comparison is true, so the OR expression is true.

25. Which is the correct syntax of the conditional operator?

a) condition ? expression1 : expression2
b) condition : expression1 ? expression2
c) expression1 ? condition : expression2
d) condition ? expression1 else expression2
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.

26. What does x = (a > b) ? a : b; assign to x?

a) The smaller value
b) The larger value
c) The sum of a and b
d) A Boolean value only
Correct Answer: b) The larger value
Explanation:
If a is greater than b, a is selected; otherwise, b is selected.

27. What is the associativity of the conditional operator in C++?

a) Left to right
b) It has no associativity
c) Right to left
d) Alphabetical order
Correct Answer: c) Right to left
Explanation:
The conditional operator groups from right to left when nested.

28. If int x = 10, what is true about if (x)?

a) It is false because 10 is not Boolean
b) It causes a compile error
c) It is true only if x equals 1
d) It is true because nonzero values convert to true
Correct Answer: d) It is true because nonzero values convert to true
Explanation:
Any nonzero integral value converts to true in a Boolean context.

29. Which statement can execute a statement only when a condition is true?

a) if
b) switch only
c) loop
d) return only
Correct Answer: a) if
Explanation:
The if statement is the basic decision-making statement in C++.

30. What happens if a semicolon is placed directly after if (x > 5), followed by a cout statement?

a) cout executes only when x > 5
b) cout executes always
c) A compile error occurs
d) cout never executes
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.

31. Which is the correct syntax for an else if branch?

a) else if condition { }
b) elseif (condition) { }
c) else if (condition) { }
d) else if condition statement
Correct Answer: c) else if (condition) { }
Explanation:
C++ uses the two keywords else and if together, with the condition in parentheses.

32. Which of the following is not a standard C++ control-flow keyword?

a) if
b) else
c) switch
d) elseif
Correct Answer: d) elseif
Explanation:
C++ uses else if as two separate keywords, not elseif.

33. What is a nested if statement?

a) An if statement inside another if statement
b) A loop inside an if statement
c) An else clause inside a loop
d) A function inside an if statement
Correct Answer: a) An if statement inside another if statement
Explanation:
Nested if statements allow decisions to depend on multiple related conditions.

34. In if (condition) statement1; statement2; without braces, when does statement2 execute?

a) Only when the condition is true
b) Always
c) Never
d) Only when braces are used
Correct Answer: b) Always
Explanation:
Only statement1 is controlled by the if statement; statement2 is outside the if body.

35. What should be used to execute multiple statements when an if condition is true?

a) A semicolon
b) A comma
c) Braces
d) Parentheses
Correct Answer: c) Braces
Explanation:
Braces create a compound statement, allowing several statements to be controlled by one if.

36. Which statement is true about an if, else if, else ladder?

a) It requires a default else
b) It cannot have more than two conditions
c) It executes all branches after a true condition
d) It checks conditions sequentially until one is true
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.

37. What is printed by int x = 3; if (x == 3) cout << 1; else cout << 2;?

a) 1
b) 2
c) 12
d) No output
Correct Answer: a) 1
Explanation:
The condition x == 3 is true, so the if branch prints 1.

38. What is printed by int x = 4; if (x > 5) cout << 1; else cout << 2;?

a) 1
b) 2
c) 4
d) Compile error
Correct Answer: b) 2
Explanation:
The condition x > 5 is false, so the else branch prints 2.

39. What is printed by int x = 0; if (x) cout << 1; else cout << 2;?

a) 1
b) 0
c) 2
d) Compile error
Correct Answer: c) 2
Explanation:
Zero converts to false, so the else branch executes.

40. What is printed by int x = 7; if (x = 7) cout << 1; else cout << 2;?

a) 2
b) Compile error
c) No output
d) 1
Correct Answer: d) 1
Explanation:
The assignment expression yields 7, which converts to true.

41. Among !, &&, ||, and =, which operator has the highest precedence?

a) !
b) &&
c) ||
d) =
Correct Answer: a) !
Explanation:
Logical NOT has higher precedence than logical AND, logical OR, and assignment.

42. Which operator has higher precedence than &&?

a) ||
b) ==
c) ?:
d) ,
Correct Answer: b) ==
Explanation:
Equality comparison is evaluated before logical AND.

43. When is if (x == 1 || x == 2) true?

a) Only when x is 1
b) Only when x is 2
c) When x is either 1 or 2
d) When x is neither 1 nor 2
Correct Answer: c) When x is either 1 or 2
Explanation:
The OR operator makes the condition true if either comparison is true.

44. When is if (x > 0 && x < 10) true?

a) When x is less than 0
b) When x is greater than 10
c) When x equals 10
d) When x is greater than 0 and less than 10
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.

45. Which condition checks that x is not equal to 5?

a) x != 5
b) x == 5
c) x = 5
d) x <> 5
Correct Answer: a) x != 5
Explanation:
The inequality operator != tests whether two values are different.

46. Which of the following is a valid Boolean expression in C++?

a) x %% 2 == 0
b) x % 2 == 0
c) x % 2 = 0
d) x ? 2 : 0 ==
Correct Answer: b) x % 2 == 0
Explanation:
The modulo and equality operators combine to form a valid expression that evaluates to true or false.

47. What does if (x % 2 == 0) test?

a) Whether x is odd
b) Whether x is negative
c) Whether x is even
d) Whether x is zero only
Correct Answer: c) Whether x is even
Explanation:
An even integer has remainder 0 when divided by 2.

48. What is the result of bool(10 < 20)?

a) false
b) 0
c) Compile error
d) true
Correct Answer: d) true
Explanation:
Ten is less than twenty, so the comparison evaluates to true.

49. Which integer value converts to false in C++?

a) 0
b) 1
c) -1
d) 100
Correct Answer: a) 0
Explanation:
Zero is the integer value that converts to false.

50. Which pointer value converts to false in C++?

a) A non-null pointer
b) A null pointer
c) A void pointer
d) Any pointer
Correct Answer: b) A null pointer
Explanation:
A null pointer converts to false, while a non-null pointer converts to true.

51. What does if (ptr) check when ptr is a pointer?

a) Whether ptr is zero
b) Whether ptr is negative
c) Whether ptr is non-null
d) Whether ptr is uninitialized
Correct Answer: c) Whether ptr is non-null
Explanation:
A pointer in a Boolean context is true when it is not null.

52. Which statement is true about an if, else if ladder?

a) It must have a final else
b) It can contain only two else if branches
c) It executes all branches after one condition is true
d) It can contain multiple else if branches
Correct Answer: d) It can contain multiple else if branches
Explanation:
C++ allows many else if branches before an optional final else.

53. What is printed by int a = 5; if (a > 1) cout << 10; cout << 20;?

a) 1020
b) 10
c) 20
d) 2010
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.

54. What is printed by int a = 5; if (a > 10) cout << 10; cout << 20;?

a) 1020
b) 20
c) 10
d) Compile error
Correct Answer: b) 20
Explanation:
The if condition is false, so only the statement after the if executes.

55. What is printed by int a = 5; if (a > 10) { cout << 10; } else { cout << 20; }?

a) 10
b) 1020
c) 20
d) Compile error
Correct Answer: c) 20
Explanation:
The condition is false, so the else block executes.

56. What is printed by int a = 5; if (a == 5) { cout << 10; } else if (a > 0) { cout << 20; }?

a) 20
b) 1020
c) 0
d) 10
Correct Answer: d) 10
Explanation:
The first condition is true, so its branch executes and the else if is skipped.

57. What is printed by int a = 5; if (a == 6) { cout << 10; } else if (a > 0) { cout << 20; }?

a) 20
b) 10
c) 30
d) No output
Correct Answer: a) 20
Explanation:
The first condition is false, but the else if condition is true.

58. What is printed by int a = 5; if (a == 6) cout << 10; else if (a == 7) cout << 20; else cout << 30;?

a) 10
b) 30
c) 20
d) Compile error
Correct Answer: b) 30
Explanation:
Neither the if nor the else if condition is true, so the final else executes.

59. What is printed by int a = 5; if (a > 0) if (a > 3) cout << 1; else cout << 2;?

a) 2
b) 12
c) 1
d) No output
Correct Answer: c) 1
Explanation:
Both conditions are true, so the inner if branch prints 1.

60. What is printed by int a = 5; if (a > 0) if (a > 10) cout << 1; else cout << 2;?

a) 1
b) No output
c) 12
d) 2
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.

61. What can be used to avoid dangling else ambiguity?

a) Braces
b) Semicolon
c) Comments
d) Multiple main functions
Correct Answer: a) Braces
Explanation:
Braces make the intended grouping of if and else explicit.

62. Which statement is true about the expression inside if (expression)?

a) The expression must be an integer
b) The expression is contextually converted to bool
c) The expression must be a string
d) The expression is ignored
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.

63. Which is a valid if statement in C++?

a) if (x > 0) else cout << 1;
b) if x > 0 cout << 1;
c) if (x > 0) cout << 1;
d) if (x > 0): cout << 1;
Correct Answer: c) if (x > 0) cout << 1;
Explanation:
The condition must be in parentheses, and no colon or then keyword is used.

64. Which of the following is invalid C++ syntax?

a) if (true) { }
b) if (false);
c) if (x) cout << x;
d) if (x) then cout << x;
Correct Answer: d) if (x) then cout << x;
Explanation:
C++ does not use the keyword then in if statements.

65. What does the break statement do?

a) It exits a loop or switch
b) It exits an if statement
c) It skips the current iteration
d) It stops the entire program always
Correct Answer: a) It exits a loop or switch
Explanation:
break terminates the nearest enclosing loop or switch statement.

66. What does the continue statement do?

a) It exits the loop
b) It skips to the next loop iteration
c) It restarts the program
d) It ends the if statement
Correct Answer: b) It skips to the next loop iteration
Explanation:
continue skips the remaining loop body and proceeds to the next iteration.

67. Which statement is true about the switch statement?

a) It can replace every if statement
b) It usually uses floating-point expressions
c) It can handle integral constant case labels
d) It cannot have a default label
Correct Answer: c) It can handle integral constant case labels
Explanation:
switch works with integral or enumeration values and constant case labels.

68. What happens in a switch statement when a matching case has no break?

a) A compile error occurs
b) The switch exits immediately
c) The default label becomes mandatory
d) Execution falls through to the next case
Correct Answer: d) Execution falls through to the next case
Explanation:
Without break, control continues into subsequent case labels.

69. Which type cannot be used directly as the controlling expression of a switch statement?

a) double
b) int
c) char
d) enum
Correct Answer: a) double
Explanation:
switch requires an integral or enumeration type, not a floating-point type.

70. Which case label is valid in C++?

a) case 1.5:
b) case 5:
c) case myVar:
d) case five:
Correct Answer: b) case 5:
Explanation:
Case labels must be integral constant expressions.

71. What is printed by switch (1) { case 1: cout << 1; break; case 2: cout << 2; }?

a) 12
b) 2
c) 1
d) No output
Correct Answer: c) 1
Explanation:
Case 1 matches, prints 1, and break prevents fallthrough.

72. What is printed by switch (1) { case 1: cout << 1; case 2: cout << 2; }?

a) 1
b) 2
c) Compile error
d) 12
Correct Answer: d) 12
Explanation:
There is no break, so execution falls through from case 1 to case 2.

73. Which statement is true about the default label in a switch statement?

a) It is optional
b) It is required
c) It must appear first
d) It can be used only with integers
Correct Answer: a) It is optional
Explanation:
A switch statement may omit the default label.

74. Which statement is true about case labels in a switch statement?

a) They can be duplicate
b) They must be constant expressions
c) They can be runtime variables
d) They can be string literals
Correct Answer: b) They must be constant expressions
Explanation:
Case labels must be unique integral constant expressions.

75. Which loop executes its body at least once before checking the condition?

a) for
b) while
c) do-while
d) if
Correct Answer: c) do-while
Explanation:
A do-while loop checks its condition after executing the body.

76. Which loop checks its condition before executing the loop body?

a) do-while
b) goto
c) switch
d) while
Correct Answer: d) while
Explanation:
A while loop evaluates its condition before each iteration.

77. What is printed by for (int i = 0; i < 3; ++i) cout << i;?

a) 012
b) 123
c) 0
d) Infinite loop
Correct Answer: a) 012
Explanation:
The loop prints 0, then 1, then 2, and stops before i becomes 3.

78. What is printed by while (false) cout << 1;?

a) 1
b) No output
c) Compile error
d) Infinite loop
Correct Answer: b) No output
Explanation:
The condition is false initially, so the body never executes.

79. What is printed by do { cout << 1; } while (false);?

a) No output
b) Compile error
c) 1
d) Infinite loop
Correct Answer: c) 1
Explanation:
The do-while body executes once before the false condition is checked.

80. Which statement creates an infinite loop?

a) for (int i = 0; i < 10; ++i) { }
b) while (false) { }
c) do { } while (false);
d) while (true) { }
Correct Answer: d) while (true) { }
Explanation:
The condition is always true, so the loop never terminates by itself.

81. Which statement is commonly used to test multiple discrete values?

a) switch
b) loop
c) return
d) typedef
Correct Answer: a) switch
Explanation:
switch selects among multiple constant case labels.

82. Which construct is usually better for testing ranges of values?

a) switch
b) if-else
c) case
d) enum
Correct Answer: b) if-else
Explanation:
if-else can use relational expressions such as greater than and less than.

83. If x is an int, what is the result of if (x = 0)?

a) The condition is true
b) A syntax error occurs
c) The condition is false
d) An infinite loop occurs
Correct Answer: c) The condition is false
Explanation:
The assignment expression yields 0, which converts to false.

84. Which symbols create a compound statement or block in C++?

a) Parentheses
b) Square brackets
c) Angle brackets
d) Braces
Correct Answer: d) Braces
Explanation:
A block is written with an opening brace and a closing brace.

85. Which statement is true about an if statement without else?

a) The program continues after the if statement
b) The program must stop
c) The program cannot compile
d) A return statement is required
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.

86. Which statement is true about the conditional operator?

a) It replaces all loops
b) It can select one of two expressions
c) It cannot return values
d) It has the same syntax as if
Correct Answer: b) It can select one of two expressions
Explanation:
The ternary operator chooses between two expressions based on a condition.

87. What is the value of y after int x = 10; int y = (x > 5) ? 1 : 2;?

a) 0
b) 2
c) 1
d) Compile error
Correct Answer: c) 1
Explanation:
The condition x > 5 is true, so the first value is selected.

88. What is the value of y after int x = 1; int y = (x > 5) ? 1 : 2;?

a) 1
b) true
c) Compile error
d) 2
Correct Answer: d) 2
Explanation:
The condition x > 5 is false, so the second value is selected.

89. What is printed by int x = 5; cout << ((x > 3) ? 10 : 20);?

a) 10
b) 20
c) 5
d) Compile error
Correct Answer: a) 10
Explanation:
The condition x > 3 is true, so 10 is selected.

90. What is printed by int x = 2; cout << ((x > 3) ? 10 : 20);?

a) 10
b) 20
c) 2
d) Compile error
Correct Answer: b) 20
Explanation:
The condition x > 3 is false, so 20 is selected.

91. Which if statement is equivalent to (a > b) ? x : y; when assigning to result?

a) if (a > b) result = y; else result = x;
b) if (a > b) result = x;
c) if (a > b) result = x; else result = y;
d) if (a > b) x = y;
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.

92. What happens with int x = 0; if (++x) cout << x;?

a) Compile error
b) It prints 0
c) No output
d) It prints 1
Correct Answer: d) It prints 1
Explanation:
Prefix increment changes x to 1, and 1 converts to true.

93. What is printed by int x = 0; if (x++) cout << 1; else cout << 2;?

a) 2
b) 1
c) 0
d) Compile error
Correct Answer: a) 2
Explanation:
Postfix increment yields the old value 0, so the condition is false.

94. What is printed by int x = 1; if (--x) cout << 1; else cout << 2;?

a) 1
b) 2
c) 0
d) Compile error
Correct Answer: b) 2
Explanation:
Prefix decrement changes x to 0, and 0 converts to false.

95. What is printed by int x = 1; if (x--) cout << 1; else cout << 2;?

a) 2
b) Compile error
c) 1
d) 0
Correct Answer: c) 1
Explanation:
Postfix decrement yields the old value 1, so the condition is true.

96. Which statement is true about using assignment inside an if condition?

a) It always causes a compile error
b) It is always recommended
c) It cannot compile
d) It may be legal but is often unintended
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.

97. Which condition correctly tests whether x is between 1 and 10 inclusive?

a) x >= 1 && x <= 10
b) 1 <= x <= 10
c) x > 1 || x < 10
d) x >= 1 && <= 10
Correct Answer: a) x >= 1 && x <= 10
Explanation:
Both comparisons must be written separately and joined with AND.

98. Why is if (1 <= x <= 10) usually wrong in C++?

a) It is a syntax error
b) It does not test the range as intended
c) It is always false
d) It cannot compile
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.

99. What happens with if (x == 5); { cout << 1; } when x is 5?

a) It prints 1 only when x equals 5
b) It causes a compile error
c) It prints 1 regardless of the condition
d) It produces no output
Correct Answer: c) It prints 1 regardless of the condition
Explanation:
The semicolon makes the if body empty, and the following block is independent.

100. What best describes control flow in a program?

a) Data storage
b) Memory allocation
c) Object creation
d) The order in which statements are executed
Correct Answer: d) The order in which statements are executed
Explanation:
Control flow determines the sequence in which program statements run.
← Previous: C++ Constructors and Destructors MCQs
Next →: C++ Exception / Error Handling - MCQs
New
No Image

C++ Exception / Error Handling - MCQs

1. What does an if statement do in C++? a) It executes a block when the condition is true b)…

By MCQs Generator
NewC++ Strings MCQs

C++ Strings MCQs

In C++, strings are handled in two primary ways: traditional C-style strings (null-terminated character arrays) and the modern std::string class…

By MCQs Generator
New
No Image

C++ Inheritance and Polymorphism - MCQs

1. What does an if statement do in C++? a) It executes a block when the condition is true b)…

By MCQs Generator