Pseudocode Notes
Pseudocode Notes
METHOD 1 METHOD 2
Start Start
write ‘Enter sides of square’ Write “Enter sides of square”
Read side Read side
Area = side x side Set A SIDE X SIDE
Print “The area is’, area. Write “The area is’,A
Stop Stop.
Method # 2 contain terms such as START, WRITE, SET and STOP. The write statement represents PRINT.
Start and Stop is the beginning and ending of the algorithm. The ARROW is similar to the equal sign, it is
stating that whatever is calculated will be stored in a variable. The SET statement stores the result of the
process or simply to initialize a variable.
*** KEYWORDS
There are several keywords that are often used to indicate common input, output and processing
operations in pseudocode.
Input - READ, OBTAIN, GET, WRITE, PRINT
Output – PRINT, DISPLAY, SHOW, WRITE
Processing – COMPUTE, CALCULATE, DETERMINE
Initialize – SET, INIT
Add one – INCREMENT, BUMP
Start Start
For x 1 to 5 itemName
Enter item name itemPrice, discount, newPrice
Read item name x
Enter item price
Read item price set newPrice := 0;
Calculate discount set discount :=0;
Discount = Item price * 0.25
Calculate new price begin
Item price – discount For x := 1 to 5 do
Print item name write(enter item name)
Print new price read(itemName)
Stop. write(enter itemPrice)
read(itemPrice)
write(Item name)
write(New price of item)
end
Stop.
In the above example, the ALGORITHM on the left was written using everyday English language. It had nothing to do
with any programming language. It simple states the STEP to be followed to solve the problem statement. In the
PSEUDOCODE ALGORITHM, you would notice that the language is a bit different. Consider the following NEW thing in
the Pseudocode algorithm that the normal algorithm (on the left) does not have.
The variables to be used in the program has been identified, no need to state the data type here, that will be
applicable only when you are writing the actual programming code.
Some of the variables have been initialized. Usually the values that the user will enter (itemPrice) are NOT
initialized, ONLY the variables whose value is unknown at the start of the program or variables that have to be
calculated are initialized (newPrice, discount).
Input/output statements are now clearly stated, however, you do not need to include the syntax (open/close
quotes, semicolon, colon etc) at this point, that is for the actual program code.
Eg
write(enter item name)
read(itemName)
*** Some of the words such as WRITE/READ can be replaced with words from the paragraph in the previous
page that speaks about KEYWORDS
Take note how the loop is to be stated in the PSEUDOCODE ALGORITHM. If conditions (if-then-else) are needed,
just incorporate it wherever it may be needed.