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

Assignment 3-2.1.2 Pseudocode and Flowcharts

This document contains pseudocode examples and problems related to algorithm design and problem solving: 1. A repeat-until loop is presented that prompts the user to enter numbers until -1 is entered, then displays the maximum and minimum numbers entered. 2. Several do-while loops are given and the number of times each loop body will execute is asked, with answers of "zero," "infinity," or "unknown" accepted. 3. A program is outlined that prompts the user for a number, checks if it is prime by testing for factors other than 1 and itself, and displays whether it is prime or not.

Uploaded by

Aditya Ghose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
282 views

Assignment 3-2.1.2 Pseudocode and Flowcharts

This document contains pseudocode examples and problems related to algorithm design and problem solving: 1. A repeat-until loop is presented that prompts the user to enter numbers until -1 is entered, then displays the maximum and minimum numbers entered. 2. Several do-while loops are given and the number of times each loop body will execute is asked, with answers of "zero," "infinity," or "unknown" accepted. 3. A program is outlined that prompts the user for a number, checks if it is prime by testing for factors other than 1 and itself, and displays whether it is prime or not.

Uploaded by

Aditya Ghose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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