Unit 4 Pseudocode Flashcards
What is pseudocode?
Pseudocode is a simplified, informal way of describing a program’s logic and algorithms using plain language, without the strict syntax of actual programming code.
What is the main purpose of pseudocode?
To help programmers plan, and visualise the structure and logic of their algorithm before writing the actual code.
What are the basic elements of pseudocode?
Keywords like BEGIN, END, IF-THEN-ELSE, WHILE, FOR, PRINT, logical conditions, and simple variable assignments.
WHILE in pseudocode
BEGIN
SET i = 1
WHILE i <= 5
PRINT i
i = i + 1
ENDWHILE
END
IF in pseudocode
BEGIN
INPUT number
IF number % 2 == 0 THEN
PRINT “The number is even”
ENDIF
END
FOR in pseudocode
BEGIN
FOR i = 2 TO 10 STEP 2
PRINT i
ENDFOR
END
THEN in pseudocode
BEGIN
INPUT value
IF value > 100 THEN
PRINT “Value is greater than 100”
ENDIF
END
ELSE in Pseudocode
BEGIN
INPUT age
IF age >= 18 THEN
PRINT “Adult”
ELSE
PRINT “Minor”
ENDIF
END