You are on page 1of 2

Computer Science Assignment # 3

2.1 Algorithm Design and Problem Solving

2.1.2 Pseudocode
1. Write a Repeat-Until loop that repeatedly prompts the user to enter a number and, once
the number -1 is typed, displays the maximum and minimum numbers that the user
entered.
Here is a sample dialogue:

[8]

2. For each of the following do/while loops, how many times will the loop execute its body?
Remember that "zero," "infinity," and "unknown" are legal answers.
(a) Declare x As Integer
x = 1
Repeat
OUTPUT x & “ “
x = x + 10
Until x < 100
[1]
(b) Declare max As Integer
max = 10
Repeat
OUTPUT “Count Down: “ & max
max = max – 1
Until max < 10
[1]
(c) Declare x As Integer
Declare count As Integer
x = 250
Repeat
OUTPUT x
count = x MOD 3
Until count <> 0
[2]
(d) Declare x As Integer
Declare count As Integer
x = 100

Page 1 of 2
Computer Science Assignment # 3
2.1 Algorithm Design and Problem Solving

2.1.2 Pseudocode
Repeat
OUTPUT x
x = x DIV 2
count = x MOD 2
UNTIL count = 0
[1]
(e) Declare x As Integer
x = 2
REPEAT
OUTPUT x + “ “
x = x * x
UNTIL x < 200
[1]
(f) Declare x As Integer
x = 100
REPEAT
OUTPUT x DIV 10
x = x DIV 2
UNTIL x > 0
[1]
3. Write a program that prompts the user to enter a number and checks that whether that
number is prime (i.e has no factors other than 1 and itself) and display that whether the
number is prime or not.
Here is a sample dialogue:
Enter a number: 5

The number is prime

[10]

Page 2 of 2

You might also like