Multiple choiceQuestion 1 · Recall
Loading…
By the end you can draw a flowchart for a given algorithm, convert a flowchart to pseudocode, and trace execution using a trace table.
Follow the flow lines from Start to End, translating each symbol:
| Flowchart symbol | Pseudocode equivalent |
|---|---|
| Oval (Start/End) | (implied by program bounds) |
| Parallelogram (Input) | READ variable |
| Parallelogram (Output) | PRINT expression |
| Rectangle (Process) | variable ← expression |
| Diamond (Decision) | IF condition THEN ... ELSE ... ENDIF |
| Predefined process | CALL procedure() |
| Connector | (labels/GOTO in code — avoid; use structured loops) |
Key rules:
Worked example: Flowchart → Pseudocode
Convert the 'find max of 3' flowchart to pseudocode
READcounter ≤ limit?PRINTWorked example: Pseudocode → Flowchart
Draw flowchart for: READ n; sum ← 0; FOR i ← 1 TO n DO sum ← sum + i ENDFOR; PRINT sum
A trace table shows variable values at each step. Columns = variables + output; rows = execution steps.
Example: READ n; sum ← 0; FOR i ← 1 TO n DO sum ← sum + i ENDFOR; PRINT sum with n=3
| Step | n | sum | i | Output |
|---|---|---|---|---|
| 1 | 3 | — | — | |
| 2 | 3 | 0 | — | |
| 3 | 3 | 0 | 1 | |
| 4 | 3 | 1 | 1 | |
| 5 | 3 | 1 | 2 | |
| 6 | 3 | 3 | 2 | |
| 7 | 3 | 3 | 3 | |
| 8 | 3 | 6 | 3 | |
| 9 | 3 | 6 | 4 | |
| 10 | 3 | 6 | 4 | 6 |
Stop when loop condition fails (i=4, 4≤3 is false). Final output is 6.