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

Mac Cse: Information Technology Algorithm Worksheet

The document contains 12 questions about algorithms and flowcharts. It involves completing trace tables for algorithms, writing algorithms to perform tasks like comparing numbers, interchanging variable values, calculating sums and maximums of input values, and drawing flowcharts to summarize temperature data over days or calculate sums of input numbers.

Uploaded by

Holsworth Wilson
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
767 views

Mac Cse: Information Technology Algorithm Worksheet

The document contains 12 questions about algorithms and flowcharts. It involves completing trace tables for algorithms, writing algorithms to perform tasks like comparing numbers, interchanging variable values, calculating sums and maximums of input values, and drawing flowcharts to summarize temperature data over days or calculate sums of input numbers.

Uploaded by

Holsworth Wilson
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

MAC CSE

Information Technology
Algorithm Worksheet

1. This following flowchart inputs two numbers, carries out a calculation and then outputs the results.

Complete the following table for the three sets of input data.

2. Read the algorithm.


(a) Complete the trace table using the
data: 1, - 5, 2, - 8, - 7.

C neg pos
1 0 0

No

Yes
(b) What is the output of the algorithm.
3. Read the algorithm.

a) Complete the trace table using the data: 9.0, 7.8, 1.2, 4.5, 10.0, 6.4, 3.1.

C high total
1 0 0

b) What is the output of the algorithm.


4 Read the algorithm.

a) Complete the trace table using the data: : 45

Number X T

What is the output of the algorithm.

b) Complete the trace table using the data: : -2


c) Complete the trace table using the data: 20
Number X T
Number X T

What is the output of the algorithm.


What is the output of the algorithm.
5. a) Write an algorithm which reads three values, a, b and c and prints the largest of the three.
(4 marks)

b) This part is based on the algorithm given below:

Start
Set A to 3
Set B to 5
Set SUM to 1
While A <= 50 do
A=A+B
B=B+A
SUM = SUM + B
Endwhlie
Print SUM
Stop

Using the algorithm above:

i) Copy and complete the trace table which follows. (5 marks)


A B SUM
3 5 1

ii) What is printed by the algorithm. (1 mark)

6. b) What is printed by the following algorithm?


SUM = 0
N = 20
WHILE N < 30 DO
SUM = SUM + N
PRINT N. SUM
N=N+3
ENDWHILE
(5 marks)

7. Write one algorithm to do the following sequence of tasks:


(a) Read in the values of two numbers
(b) Find the product of the two numbers
(c) Find the sum of the two numbers
(d) Check whether the product is bigger than the sum.
(e) If the product is bigger, it must print a message to say so, and if the product is not bigger it must
print a message saying that the product is not bigger.
(7 marks)
8. Consider the following routine:
INPUT X, Y
Z = X*X + Y*Y
PRINT “The sum of square is”; Z

For each of the first two lines of code, write a comment to indicate what the code does.
(2 marks)

9 Write an algorithm to interchange the values in two variables A and B. (2 marks)

10. (a) Draw a flowchart which takes temperatures input over a 7 day period
(once per day) and outputs the number of days when the temperature was below 20°C and the number of
days when the temperature was 20°C and above.

(b)Write a pseudocode algorithm for the same instruction above.

11. Draw a flowchart to accept five numbers one each time, calculate and output the sum of the numbers.

12. Write an algorithm to read any ten numbers, calculate their sum and print it as well as the highest number in the list.

You might also like