Pseudocode Mapping
Throughout these lessons, you've been seeing flowcharts and pseudocode side by side. Now it's time to make the connection crystal clear. Every flowchart shape maps to a specific pseudocode pattern, and every line of pseudocode can be drawn as a flowchart shape. Once you learn these mappings, you can translate freely between the two.
Pseudocode is a way of writing out program logic in plain English, structured like code but without worrying about a specific programming language. It's the text version of a flowchart.
The Mapping Table
Here's the master reference. Each flowchart shape has a matching pseudocode pattern:
| Flowchart Shape | Meaning | Pseudocode |
|---|---|---|
|
Oval (Terminal) |
Start or End | BEGIN / END |
|
Rectangle (Process) |
Action or assignment | SET x = 5total = total + 1 |
|
Diamond (Decision) |
Yes/No question | IF ... THENWHILE ...FOR EACH ... |
|
Parallelogram (I/O) |
Input or Output | INPUT nameOUTPUT "Hello" |
Pseudocode Keywords
Here are the pseudocode keywords you've learned in these lessons. They're not tied to any real programming language — they're just clear English words that describe what's happening.
BEGIN / END
Start and finish the program
SET
Create or assign a variable
INPUT
Get data from the user
OUTPUT
Show data to the user
IF / THEN / ELSE
Make a decision
WHILE / END WHILE
Loop while condition is true
FOR EACH / IN
Loop through a list
END IF
End a decision block
Putting It All Together
Here's a complete program that uses everything you've learned: variables, input, output, an if-else statement, and a while loop. It's a guessing game — the computer picks a number and you keep guessing until you get it right.
Step through the flowchart and pseudocode together. Notice how each shape in the flowchart corresponds to exactly one line (or block) in the pseudocode.
BEGIN
SET secret = 7
SET guess = 0
WHILE guess != secret
OUTPUT "Enter your guess:"
INPUT guess
IF guess < secret THEN
OUTPUT "Too low!"
ELSE
OUTPUT "Too high!"
END IF
END WHILE
OUTPUT "Correct! You got it!"
END
Variable Watch
| Variable | Value |
|---|---|
| Step through to see variables | |
This program combines variables (secret, guess), input/output (asking for guesses, showing hints), a while loop (keep guessing until correct), and an if-else (is the guess too low or too high?). Every concept from the previous lessons works together!
Translation Rules: Flowchart to Pseudocode
When you want to convert a flowchart into pseudocode, follow these steps:
- Start at the top — write
BEGIN. - Follow the arrows — each shape becomes one line (or block) of pseudocode.
- Rectangles become assignment statements:
SET x = value - Parallelograms become
INPUTorOUTPUTstatements. - Diamonds become
IF,WHILE, orFOR EACH— look at whether the No arrow goes forward (it's an if) or backward (it's a loop). - Indent everything inside an if-block or loop body.
- End at the bottom — write
END.
The big clue for loops vs. decisions: If a diamond has an arrow that goes back up in the flowchart, it's a loop. If all arrows go forward/down, it's an if statement.
Translation Rules: Pseudocode to Flowchart
Going the other direction — pseudocode to flowchart — use these rules:
BEGINandENDbecome oval shapes at the top and bottom.SET/ assignment statements become rectangles.INPUT/OUTPUTbecome parallelograms.IF ... THENbecomes a diamond with Yes and No arrows going forward.WHILE ...becomes a diamond with the Yes arrow going to the loop body and the No arrow going forward. At the end of the loop body, draw an arrow back up to the diamond.FOR EACH ... IN ...works the same way as while — diamond with a back arrow.- Connect everything with arrows, flowing top to bottom.
Quick Reference Card
Here's a cheat sheet showing each structure as both a mini flowchart and pseudocode:
If Statement
IF condition THEN do something END IF
Diamond with one action on the Yes path. No path skips ahead.
If-Else Statement
IF condition THEN do this ELSE do that END IF
Diamond with actions on both Yes and No paths.
While Loop
WHILE condition do something update variable END WHILE
Diamond with a back arrow from the loop body. Needs an update step.
Foreach Loop
FOR EACH item IN list do something with item END FOR EACH
Diamond asking "more items?" with back arrow. No counter needed.
Key Takeaways
- Every flowchart shape maps directly to a pseudocode pattern — and vice versa.
- Ovals =
BEGIN/END. Rectangles = assignments. Parallelograms =INPUT/OUTPUT. Diamonds = decisions or loops. - The key difference between a decision and a loop: loops have a back arrow, decisions don't.
- You can translate in either direction once you know the mappings.
- Real programs combine multiple structures together — and now you know how to read all of them!
Congratulations! You've completed all the lessons. You now know how to read and create flowcharts for all the core programming concepts. Head over to the Flowchart Builder to practice making your own diagrams!