Writing Algorithms Style 1

There are no hard rules about writing pseudocode so you should write in the style you are most familar with. They style below is similar to Python.

1) Variables – what variables will you need and what datatype should they be? Do they need to be set to a value at the beginning.

INT score = 0
STR name

2) Loops – you will normally require a process to repeat a number of times

while count <5
    print count
    count = count + 1
end while # we just add this to make it clear that the loop has ended
for i in range (0,5)
     print count
end for # we add this to make it clear that the loop has ended

3) Conditions – you may only want parts of the program to work if a condition is met.

if score > 10:
    print you win
else
     print you lose
end if  # we just add this in to make it clear that the if statement has ended

4) Calculations – do values need to be added or multiplied. Will these be in the loop or after the loop?

total = score + bonus

count = count + 1

5) Output – What do you need to output? Will this be in the loop or after the loop

print score

print total
%d bloggers like this: