Pseudocode
Think of Pseudocode as a bridge between normal human language and a computer program.
- "Pseudo" means fake or imitation, and "code" means computer instructions.
- So, pseudocode is fake code. It looks a bit like a real program, but it uses simple English so anyone can understand the logic easily without worrying about strict computer grammar.
Simple Rules for Writing Pseudocode
- Keep it simple: Use clear English words like
PRINT,INPUT,IF, andELSE. - Use Indentation: Lines that depend on a condition (like choices or loops) must be shifted slightly to the right so it's easy to see what belongs together.
Examples
Example 1: Checking Pass or Fail (Simple Decision)
Let's check if a student passed an exam based on their marks:
IF student's marks >= 40
PRINT "Pass"
ELSE
PRINT "Fail"
ENDIF
Example 2: Finding the Greater of Two Numbers
Let's see which of two numbers is bigger:
INPUT num1, num2
IF num1 > num2
PRINT "Num1 is greater"
ELSE
PRINT "Num2 is greater"
ENDIF
Example 3: Adding 10 Numbers (Using a Loop)
When you want to repeat a step multiple times:
Set sum := 0
Set counter := 1
WHILE counter <= 10
INPUT num
sum := sum + num
increment counter by 1
ENDWHILE
PRINT "The total sum is", sum
Try it Yourself 👍
Practice writing pseudocode for these simple problems:
- Check if a given number is Even or Odd.
- Find whether a person is Eligible to Vote (Age >= 18).
