Algorithms & Flow Control MCQs for NSCT
Algorithms & Flow Control is about reading and writing step-by-step solutions: pseudocode, flowcharts, and the three control structures (sequence, selection and loops) that decide which step runs next. It is the fourth topic in Problem Solving and Analytical Skills, the area that carries 20% of the NSCT according to HEC's Areas of Competencies. In 2026 candidates averaged 49.1% in this area, per the HEC NSCT report and APP.
An algorithm is a finite, unambiguous sequence of steps that turns inputs into outputs. Knuth lists five properties: finiteness, definiteness, input, output and effectiveness. Questions on this topic mostly ask you to trace a short algorithm by hand, so the skill is careful, line-by-line reading.
Pseudocode
Pseudocode is an informal, language-independent description of an algorithm. It uses keywords such as IF, WHILE and OUTPUT but has no fixed syntax and is never compiled. Most exam pseudocode uses ← for assignment, MOD for remainder and DIV for integer division.
total ← 0
FOR i ← 1 TO 10
IF i MOD 2 = 0 THEN
total ← total + i
END IF
END FOR
OUTPUT total // 2 + 4 + 6 + 8 + 10 = 30
Exam angle: note whether FOR i ← 1 TO 10 includes 10. In standard pseudocode it does, unlike Python's range(1, 10).
Flowcharts
A flowchart shows the same logic as connected symbols. Learn the five standard shapes:
| Symbol | Meaning | Example |
|---|---|---|
| Oval (terminator) | Start or end | Start, Stop |
| Parallelogram | Input or output | Read n, Print sum |
| Rectangle | Process | sum ← sum + n |
| Diamond | Decision (one entry, Yes/No exits) | Is n > 0? |
| Small circle | On-page connector | A → A |
A loop in a flowchart is simply a flow line that goes back up to an earlier box. Exam angle: check where the decision sits. If it comes after the process boxes, the loop is post-test and its body always runs at least once.
Sequence
Sequence means statements run one after another, in order, and each assignment overwrites the old value. For a ← 3, b ← a + 2, a ← b * 2, the final values are a = 10 and b = 5. Exam angle: the classic trap is a swap without a temporary variable, where the first assignment destroys a value that the second one needs.
Selection
Selection chooses between paths: IF ... THEN ... ELSE for two ways, and IF ... ELSE IF chains or CASE for many. In an ELSE IF chain only the first true branch runs, so the order of the conditions matters. Test the narrowest condition first: marks >= 85 before marks >= 70 before marks >= 50.
Exam angle: try boundary values (exactly 70, exactly 0). Most selection bugs are a > that should be >=.
Loops
Iteration repeats a block. The three common forms differ in when they test:
| Loop | Test | Minimum runs | Best for |
|---|---|---|---|
| FOR i ← 1 TO n | Counter, fixed in advance | 0 | Known number of repeats |
| WHILE condition DO | Before the body (pre-test) | 0 | Repeat while data says so |
| REPEAT ... UNTIL condition | After the body (post-test) | 1 | Input that must be read at least once |
Note that REPEAT-UNTIL stops when its condition becomes true, while WHILE continues while its condition is true. Exam angle: count iterations exactly. A loop that doubles i from 1 up to n runs about log2(n) times, not n/2. Nested loops multiply, or add up to a triangle number when the inner bound depends on the outer variable.
Common traps in Algorithms & Flow Control questions
- Off-by-one bounds:
i < nversusi <= ndecides whether the last element is processed. - Order inside the loop: printing before or after incrementing shifts every output by one.
- Sentinel processed as data: testing for -1 after adding it to the total corrupts the result.
- Loops that never end:
WHILE i ≠ 0with i stepping by 3 can jump over zero. - ELSE IF order: a wide condition placed first hides every narrower branch below it.
- Short-circuit order:
i <= n AND A[i] ≠ keyis safe; the reverse order can read past the end of the array.
Worked examples
1. Understanding. Which flowchart symbol holds the step total ← total + price?
Answer: a rectangle. It is a calculation (a process). Inputs and outputs use parallelograms and yes/no tests use diamonds.
2. Application. What are the final values of x and y?
x ← 0
WHILE x < 3 DO
x ← x + 1
END WHILE
y ← 7
REPEAT
y ← y + 1
UNTIL y > 3
Answer: x = 3, y = 8. The WHILE loop runs three times and stops when 3 < 3 is false. The REPEAT body runs once before its first test, making y 8, and 8 > 3 ends it.
3. Analysis. This pseudocode should print 1 to 5 but prints 2 to 6. What is the fix?
i ← 1
WHILE i <= 5 DO
i ← i + 1
OUTPUT i
END WHILE
Answer: swap the two lines in the body so OUTPUT i comes before i ← i + 1. The increment happens before printing, so the first value shown is 2, and the last pass (i = 5) prints 6. Changing the bound to i < 5 would print 2 to 5, which is still wrong.
Practise Algorithms & Flow Control MCQs
The quiz below has 100 questions you can filter by tier (understanding, application, analysis) and difficulty, each with a full explanation.
Practise: 100 questions
FAQs
Is Algorithms & Flow Control part of the NSCT syllabus?
Yes. It is one of the 16 topics HEC lists under Problem Solving and Analytical Skills in the Areas of Competencies, and that area carries 20% of the test. Expect it to overlap with debugging and code-tracing topics, because all of them ask you to follow logic step by step.
Do I need to know a programming language for these questions?
Not deeply. Most questions use pseudocode or flowcharts, which you can read with basic logic. Knowing one language such as Python or C++ helps, because loops and IF statements work the same way. Watch for differences: pseudocode FOR loops usually include the upper bound, while Python's range() excludes it.
How do I trace a loop quickly without mistakes?
Draw a small trace table with one column per variable and one row per iteration. Update the values in exactly the order the lines appear, and write down the condition result at each test. It feels slow at first, but it stops the off-by-one and order errors that cost most marks here.
What is the difference between a flowchart and pseudocode?
They describe the same algorithm in different forms. A flowchart is visual, using standard shapes joined by arrows, so it shows branching clearly. Pseudocode is text, closer to real code and easier to write for longer algorithms. Exam questions may give either one, or ask you to match a flowchart to its pseudocode.
Next step
Move on to Data Representation & Abstraction MCQs, revisit Logical Reasoning if conditions trip you up, or browse the full Problem Solving MCQs hub. When you are ready, time yourself in a NSCT mock test.