0% found this document useful (0 votes)
4 views

Computer Science coursework

Uploaded by

Raaga Suravarapu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Computer Science coursework

Uploaded by

Raaga Suravarapu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1: Write pseudo code that reads two numbers and multiplies them together and print out

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

3: Write pseudo code that performs the following: -

Ask a user to enter a number.


If the number is between 0 and 10, write the word blue.
If the number is between 10 and 20, write the word red.
if the number is between 20 and 30, write the word green.
If it is any other number, write that it is not a correct color option.

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

if NUM1 > NUM2 then


TEMP = NUM1
NUM1 = NUM2
NUM2 = TEMP
end if

if NUM2 > NUM3 then


TEMP = NUM2
NUM2 = NUM3
NUM3 = TEMP
end if

if NUM1 > NUM2 then


TEMP = NUM1
NUM1 = NUM2
NUM2 = TEMP
end if

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

Output "Final sum = ", SUM

You might also like