Pseudocode & Flowcharts — Planning Your Code
Learn to plan your programs with pseudocode and flowcharts before writing actual code, making complex problems simpler.
What is Pseudocode?
Pseudocode Example: Guessing Game
PROGRAM: Number Guessing Game
SET secret_number to random number between 1 and 100
SET attempts to 0
REPEAT:
ASK user for their guess
ADD 1 to attempts
IF guess equals secret_number THEN
PRINT 'You got it in ' + attempts + ' tries!'
END GAME
ELSE IF guess is too high THEN
PRINT 'Too high! Try lower.'
ELSE
PRINT 'Too low! Try higher.'
UNTIL guess equals secret_numberWhat is a Flowchart?
When writing pseudocode, use consistent keywords like IF/THEN/ELSE, WHILE/REPEAT, SET, PRINT, and INPUT. Indent nested blocks just like real code. There is no 'wrong' way to write pseudocode as long as another person can read it and understand what the program should do.
Write pseudocode for these programs (do not write real code, just the logic in plain English): 1) A program that asks the user for their age and tells them if they can vote (18 or older), drive (16 or older), or neither. 2) A program that finds the largest number in a list. 3) A simple calculator that takes two numbers and an operation (+, -, *, /) and gives the result. For bonus points, draw a flowchart for one of them using diamonds for decisions and rectangles for actions!
Ready to build?
Put what you learned into practice — pick a project and start coding.
Start Building Free