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

Q & A Algorithm

The algorithm takes in a set of marks as input, adds them to a running sum if the counter is less than or equal to 4, and increments the counter each time. It stops when the input mark is -100 and prints out the final sum and counter value.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Q & A Algorithm

The algorithm takes in a set of marks as input, adds them to a running sum if the counter is less than or equal to 4, and increments the counter each time. It stops when the input mark is -100 and prints out the final sum and counter value.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Study the algorithm below and answer the questions that follow.

(NB. In this algorithm <= implies less than or equal to)


Set counter to zero
Begin
Input mark
If counter <=4 then
Add 1 to counter
Add mark to sum
End if
Until mark =-100
Print sum
Print counter
(i)Complete the trace table for the algorithm using the following set of marks:
25, 20, 23, 24, 20, 30,-100

MARK SUM COUNTER

0 0

25 25 1

20 45 2

23 68 3

24 92 4

20 112 5

30 112 5

-100 112 5

(ii)What is the purpose of the algorithm?

-to find the sum of the 5 marks

You might also like