Pseudocodes
structured English for defining
algorithms
Programming Constructs
represent the logic or flow of control in
an algorithm
Programming
Constructs
Linear Progression
SEQUENCE Loop with a conditional
WHILEtest
IF-THEN-Decision between 2
ELSEalternatives
Multiple Decision Points
FOR based on values
Recursive Counting
CASE Loop
Sequence
Linear progression
One task after another
Aligned with the same indent
Keywords
Input
Output READ, OBTAIN, GET
Compute PRINT, DISPLAY, SHOW
COMPUTE, CALCULATE,
Initialize DETERMINE
Add One SET, INIT
INCREMENT, BUMP
READ height of rectangle
READ width of rectangle
COMPUTE area as height times
width
IF-THEN-ELSE
IF condition THEN
Sequence 1
ELSE
Sequence 2
ENDIF
If a student gets a grade of 60 and
above, then the student passes the
course; otherwise, the student fails.
WHILE
Conditional Loop
Evaluation after each iteration
Condition must be satisfied to end
WHILE condition
SEQUENCE
WHILE Population < Limit
Compute Population as Population +
Births Deaths
Compute for the class
average of ten quiz scores.
CASE
Indicates a multi-way branch based
on mutually exclusive conditions
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
condition n : sequence n
CASE grade OF
A : print points = 4
B : print points = 3
C : print points = 2
D : print points = 1
F : print points = 0
FOR
a specialized construct for iterating a
specific number of times, often called a
"counting" loop
FOR iteration bounds
sequence
FOR grade = 94 to
100Student gets an A
Add 1 to A grade counter
Nested Constructs
Constructs embedded within each
other
Indicated by indentation
If a student gets a grade of 60 and above, the
student passes the course, if the student gets a
grade of 75 or greater, then the student qualifies for
a special course.
If a player rolls a dice and gets 6, he gets
100 pesos. If the value is 5 then he or she
gets another shot; Else, he gets nothing.
Exercises
Subtract 2 numbers. If the result is
positive, say Positive; if the result
is negative, say Negative. If the
result is 0, say Zero
Mark a 10 question test and compute
a grade on a 10-point scale. Convert
the score to a letter grade based on
the following:
A= 90-100 C= 70-79
B= 80-89 F = 69 and below