20 min read
Pseudocode Basics
Structured English for planning code: INPUT, OUTPUT, assignment, and how each flowchart symbol becomes a line of pseudocode.
What Is Pseudocode?
"Pseudo" means "not real". Pseudocode is not run by a computer, so small differences in style do not matter — but it must be clear, step by step and structured (with indentation), so that any programmer could turn it into real code.
Keywords Used in This Course
| Pseudocode keywords | ||
|---|---|---|
From Flowchart to Pseudocode
Each symbol has a matching line
| Flowchart symbol | Pseudocode |
|---|---|
| Terminator: Start / Stop | BEGIN / END |
| Parallelogram: INPUT price | INPUT price |
| Rectangle: total = price × quantity | total ← price × quantity |
| Parallelogram: OUTPUT total | OUTPUT total |
| Diamond with Yes/No exits | IF … THEN … ELSE … ENDIF |
| Diamond with an arrow back up | WHILE … ENDWHILE (or FOR / REPEAT) |
A Sequence in Pseudocode
Bill with 18% VATPseudocode
BEGIN INPUT price INPUT quantity total ← price × quantity vat ← total × 0.18 total ← total + vat OUTPUT "Amount to pay: ", totalENDWriting Good Pseudocode
- One instruction per line.
- Capital letters for keywords (INPUT, IF, WHILE); meaningful names for variables.
- Indent the lines inside IF, WHILE and FOR blocks.
- Use ← (or =) for assignment consistently.
- Close every block: ENDIF, ENDWHILE, NEXT (or ENDFOR).
Practice
What does total ← total + price mean?
More lessons in Algorithms, Flowcharts and Pseudocode · Next: Pseudocode for Selection and Loops · Previous: Reading and Completing Flowcharts
