Computer Science coursework
Computer Science coursework
their product.
start
input NUM1
input NUM 2
PRODUCT = NUM 1 * NUM 2
output PRODUCT
end
2: Write pseudo code that tells a user that the number they entered is not a 5 or a 6.
start
input NUM
if NOT NUM = 5 AND NOT NUM = 6
output (“Entered number is not 5 or 6”)
end if
end
Start
input NUMBER
if NUMBER >= 0 and NUMBER <= 10 then
output "blue"
else if NUMBER > 10 and NUMBER <= 20
output "red"
else if NUMBER > 20 and NUMBER <= 30
output "green"
else
output "It is not a correct color option"
end if
end
4: Write pseudo code to print all multiples of 5 between 1 and 100 (including both 1 and
100).
loop N from 1 to 100
if N mod 5 = 0
output N
end if
end loop
5: Write pseudo code that will count all the even numbers up to a user defined stopping
point.
input STOPNUM
COUNT = 0
loop N from 1 to STOPNUM
if N mod 2 = 0
COUNT = COUNT + 1
end if
end loop
output "Total even numbers = ", COUNT
6: Write pseudo code that reads in three numbers and writes them all in sorted order.
Input NUM1
Input NUM2
Input NUM3
Output NUM1
Output NUM2
Output NUM3
7: Write pseudo code that will calculate a running sum. A user will enter numbers that
will be added to the sum and when a negative number is encountered, stop adding
numbers and write out the final result.
SUM = 0
loop
Input NUM
if NUM < 0
break
end if
SUM = SUM + NUM
end loop