Control Flow Statements In C Plus Plus — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Control Flow Statements In C Plus Plus — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: for (int i = 5; i >= 0; --i) { cout << i << " "; if (i == 3) break; } in C++?
Correct Answer: Option B — 5 4 3
Detailed Academic Explanation:
The given code is a for loop in C++: for (int i = 5; i >= 0; --i) { cout << i << " "; if (i == 3) break; } This loop initializes i to 5 and decrements it in each iteration until i becomes less than 0. On each iteration, it prints the current value of i followed by a space. When i becomes 3, the if condition becomes true and the break statement terminates the loop. Therefore, the values printed are: 5 4 3 No further values (like 2, 1, 0) are printed because the loop exits when i == 3. Hence, the correct output is: 5 4 3
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } } in C++?
Correct Answer: Option C — 00 01 10 11 20 21
Detailed Academic Explanation:
Solution: The code contains a nested for loop structure. The outer loop iterates with variable i from 0 to 2 (inclusive), and the inner loop iterates with variable j from 0 to 1 (inclusive). For each iteration of the outer loop (each value of i ), the inner loop runs completely, iterating through both values of j . The output is printed as follows: When i = 0 : j = 0 → output is 00 j = 1 → output is 01 When i = 1 : j = 0 → output is 10 j = 1 → output is 11 When i = 2 : j = 0 → output is 20 j = 1 → output is 21 Combining all outputs, the final result is: 00 01 10 11 20 21
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int x = 10; if (x < 5) cout << "Less"; else if (x == 5) cout << "Equal"; else cout << "More"; in C++?
Correct Answer: Option A — More
Detailed Academic Explanation:
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
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'if' statement in C++?
Correct Answer: Option D — if (condition) { statement; }
Detailed Academic Explanation:
if (condition) { statement; } is the correct answer to “What is the syntax for the 'if' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'else' statement in C++?
Correct Answer: Option C — Executes when the 'if' condition is false
Detailed Academic Explanation:
Executes when the 'if' condition is false is the correct answer to “What is the purpose of the 'else' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for the 'switch' statement in C++?
Correct Answer: Option B — switch (expression) { case constant1: statement1; break; case constant2: statement2; break; default: defaultStatement; }
Detailed Academic Explanation:
switch (expression) { case constant1: statement1; break; case constant2: statement2; break; default: defaultStatement; } is the correct answer to “What is the correct syntax for the 'switch' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int x = 10; if (x > 5) cout << "Hello"; else cout << "Goodbye"; in C++?
Correct Answer: Option C — Hello
Detailed Academic Explanation:
Hello is the correct answer to “What will be the output of the following code: int x = 10; if (x > 5) cout << "Hello"; else cout << "Goodbye"; in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'break' statement do in a loop in C++?
Correct Answer: Option D — Terminates the loop
Detailed Academic Explanation:
Terminates the loop is the correct answer to “What does the 'break' statement do in a loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for the 'while' loop in C++?
Correct Answer: Option A — while (condition) { statement; }
Detailed Academic Explanation:
while (condition) { statement; } is the correct answer to “What is the correct syntax for the 'while' loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int i = 0; while (i < 5) { cout << i << " "; i++; } in C++?
Correct Answer: Option D — 0 1 2 3 4
Detailed Academic Explanation:
0 1 2 3 4 is the correct answer to “What will be the output of the following code: int i = 0; while (i < 5) { cout << i << " "; i++; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'default' case in a 'switch' statement in C++?
Correct Answer: Option C — Executes when no case matches
Detailed Academic Explanation:
Executes when no case matches is the correct answer to “What is the purpose of the 'default' case in a 'switch' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'do-while' loop in C++?
Correct Answer: Option B — do { statement; } while (condition)
Detailed Academic Explanation:
do { statement; } while (condition) is the correct answer to “What is the syntax for the 'do-while' loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, what is the difference between the 'while' loop and the 'do-while' loop?
Correct Answer: Option C — 'while' loop checks condition before execution, 'do-while' loop checks after execution
Detailed Academic Explanation:
'while' loop checks condition before execution, 'do-while' loop checks after execution is the correct answer to “In C++, what is the difference between the 'while' loop and the 'do-while' loop”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'if-else if-else' statement in C++?
Correct Answer: Option A — Provides multiple conditions to be tested
Detailed Academic Explanation:
Provides multiple conditions to be tested is the correct answer to “What is the purpose of the 'if-else if-else' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } }?
Correct Answer: Option D — 00 01 10 11 20 21
Detailed Academic Explanation:
00 01 10 11 20 21 is the correct answer to “What will be the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } }”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'if-else' statement in C++?
Correct Answer: Option C — if (condition) { statement; } else { statement; }
Detailed Academic Explanation:
if (condition) { statement; } else { statement; } is the correct answer to “What is the syntax for the 'if-else' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'else if' statement allow in C++?
Correct Answer: Option B — Additional condition checks
Detailed Academic Explanation:
Additional condition checks is the correct answer to “What does the 'else if' statement allow in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int x = 10; if (x == 10) { cout << "x is 10"; } else { cout << "x is not 10"; } in C++?
Correct Answer: Option C — x is 10
Detailed Academic Explanation:
x is 10 is the correct answer to “What is the output of the following code: int x = 10; if (x == 10) { cout << "x is 10"; } else { cout << "x is not 10"; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'continue' statement in a loop in C++?
Correct Answer: Option D — Skips the current iteration
Detailed Academic Explanation:
Skips the current iteration is the correct answer to “What is the purpose of the 'continue' statement in a loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int i = 0; while (i < 3) { cout << i << " "; i++; } in C++?
Correct Answer: Option D — 0 1 2
Detailed Academic Explanation:
0 1 2 is the correct answer to “What will be the output of the following code: int i = 0; while (i < 3) { cout << i << " "; i++; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 2) continue; cout << i << " "; } in C++?
Correct Answer: Option B — 0 1 3 4
Detailed Academic Explanation:
0 1 3 4 is the correct answer to “What will be the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 2) continue; cout << i << " "; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int x = 5; switch (x) { case 1: cout << "One"; break; case 5: cout << "Five"; break; } in C++?
Correct Answer: Option D — Five
Detailed Academic Explanation:
Five is the correct answer to “What is the output of the following code: int x = 5; switch (x) { case 1: cout << "One"; break; case 5: cout << "Five"; break; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'for' loop in C++?
Correct Answer: Option D — for (initialization; condition; update) { statement; }
Detailed Academic Explanation:
for (initialization; condition; update) { statement; } is the correct answer to “What is the syntax for the 'for' loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'do' keyword represent in the 'do-while' loop syntax in C++?
Correct Answer: Option B — Represents the loop body
Detailed Academic Explanation:
Represents the loop body is the correct answer to “What does the 'do' keyword represent in the 'do-while' loop syntax in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'if' statement with multiple conditions in C++?
Correct Answer: Option C — if (condition1 && condition2) { statement; }
Detailed Academic Explanation:
if (condition1 && condition2) { statement; } is the correct answer to “What is the syntax for the 'if' statement with multiple conditions in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int x = 5; x > 2 ? cout << "Yes" : cout << "No"; in C++?
Correct Answer: Option D — Yes
Detailed Academic Explanation:
Yes is the correct answer to “What will be the output of the following code: int x = 5; x > 2 ? cout << "Yes" : cout << "No"; in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, what is the purpose of the 'do-while' loop?
Correct Answer: Option C — Executes a block of code repeatedly until a condition becomes false
Detailed Academic Explanation:
Executes a block of code repeatedly until a condition becomes false is the correct answer to “In C++, what is the purpose of the 'do-while' loop”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 3) continue; cout << i << " "; } in C++?
Correct Answer: Option D — 0 1 2 4
Detailed Academic Explanation:
0 1 2 4 is the correct answer to “What will be the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 3) continue; cout << i << " "; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'else if' statement in C++?
Correct Answer: Option A — else if (condition) { statement; }
Detailed Academic Explanation:
else if (condition) { statement; } is the correct answer to “What is the syntax for the 'else if' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'default' case represent in a 'switch' statement in C++?
Correct Answer: Option D — Executes when no other case matches
Detailed Academic Explanation:
Executes when no other case matches is the correct answer to “What does the 'default' case represent in a 'switch' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax for the 'do-while' loop in C++?
Correct Answer: Option C — do { statement; } while (condition)
Detailed Academic Explanation:
do { statement; } while (condition) is the correct answer to “What is the correct syntax for the 'do-while' loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the syntax for the 'switch' statement in C++?
Correct Answer: Option D — switch (expression) { case constant1: statement1; break; case constant2: statement2; break; default: defaultStatement; }
Detailed Academic Explanation:
switch (expression) { case constant1: statement1; break; case constant2: statement2; break; default: defaultStatement; } is the correct answer to “What is the syntax for the 'switch' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, what is the purpose of the 'if-else' statement?
Correct Answer: Option A — Allows execution of different blocks of code based on a condition
Detailed Academic Explanation:
Allows execution of different blocks of code based on a condition is the correct answer to “In C++, what is the purpose of the 'if-else' statement”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: int i = 5; if (i != 5) cout << "Not equal"; else cout << "Equal"; in C++?
Correct Answer: Option D — Equal
Detailed Academic Explanation:
Equal is the correct answer to “What will be the output of the following code: int i = 5; if (i != 5) cout << "Not equal"; else cout << "Equal"; in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'if' statement in C++?
Correct Answer: Option C — Executes a block of code if a condition is true
Detailed Academic Explanation:
Executes a block of code if a condition is true is the correct answer to “What is the purpose of the 'if' statement in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: int i = 0; do { cout << i << " "; i++; } while (i < 3); in C++?
Correct Answer: Option B — 0 1 2
Detailed Academic Explanation:
0 1 2 is the correct answer to “What is the output of the following code: int i = 0; do { cout << i << " "; i++; } while (i < 3); in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'continue' statement do in a loop in C++?
Correct Answer: Option D — Skips the current iteration and continues with the next iteration
Detailed Academic Explanation:
Skips the current iteration and continues with the next iteration is the correct answer to “What does the 'continue' statement do in a loop in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 3) continue; cout << i << " "; } in C++?
Correct Answer: Option C — 0 1 2 4
Detailed Academic Explanation:
0 1 2 4 is the correct answer to “What is the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 3) continue; cout << i << " "; } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } } in C++?
Correct Answer: Option D — 00 01 10 11
Detailed Academic Explanation:
00 01 10 11 is the correct answer to “What will be the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } } in C++”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C++, what is the syntax for the 'while' loop?
Correct Answer: Option C — while (condition) { statement; }
Detailed Academic Explanation:
while (condition) { statement; } is the correct answer to “In C++, what is the syntax for the 'while' loop”. This question is standard in competitive examination syllabi for Control Flow Statements In C Plus Plus.
💡Key Conceptual Anchor:Control Flow Statements In C Plus Plus
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.