1
Unit 01: Algorithm Design and Problem solving
Name: Date: Marks: /50
4. Four Statement types and four examples are bellow.
Paper | 2
(a) Draw a line to connect each type of statement to the examples(s) it applies to.
FOR X 1 TO 10 Assignment
READ X Iteration
PRINT X Input
Total Sum + 2 Output
[4]
(b) (i) Identify the correct two different types of condition statement :
a condition that can be true or false: ---------------------------------------------------.
a choice between several different values: ------------------------------------------ [2]
(ii) Identify the correct three different types of loop structure :
a set number of repetitions: ----------------------------------------------------------------------------------------.
a repetition, where the number of repeats is not known, that is completed at least one: ---------------------
a repetition, where the number of repeats is not known, that may never be completed: ------------------[3]
5. (a) Describe each of the following data types used in programming.
In each case, give an example of a piece of data to illustrate your answer.
Char : Description ....................................................................................................................
……………………………..……………..…………………………………………...……...
Example ....................................................................................................................................
Boolean : Description ..............................................................................................................
……………………………..……………..……………………..…………………………....
Example ............................................................................................................................... [4]
(b) Draw a line to connect each data structure to the correct description
Data Structure Description
Constant a value that can change whilst a program is running
Variable a value that never changes whilst a program is running
[2]
(c) Name the three types of loop structure used in pseudocode.
1................................................................................................................................................
2 ...............................................................................................................................................
3 ...........................................................................................................................................[3]
© HEGICT 2024 2210/ P2 / Unit Assessment 01 / Summer 2024
2
6. (a) A program to find the Total of the Mark and counting the number of Student Fail.
Total is stored in a variable TotalMark and the number of Fail is stored in a variable FailCount.
Explain, including examples of programming statements, how these terms could be used.
TotalMark ..................................................................................................................................
……………………………..……………..…………………………………………...……...
Paper | 2
FailCount ...................................................................................................................................
……………………………..……………..……………...………..………………………[4]
(b) Read the section of program code for attempting the following question.
01 Total = 0
02 FOR Index = 1 TO 25
03 INPUT Number
04 IF Number > 0 THEN
05 Total=Total + Number
06 ENDIF
07 NEXT Index
08 OUTPUT (Total/Index)
Give the line number for the statements showing:
Assignment ------- Calculating the average -------
Totalling ------- Selection -------
Counter Variable ------- Iteration -------
[4]
7. Study the pseudocode
1. SET Total to Zero
2. INPUT Number
3. FOR COUNTER = 1 TO Number
4. INPUT Mark
5. Total = Total + Mark
6. NEXT COUNTER
7. OUTPUT Total / Number
(a) Dry run the algorithm using the following data. 3, 5, 6, 7, 8, 10 ,12
(i) Write down the final value of Total.….......................................................................……...…...[1]
(ii) Write down the value output .…............…….....................................................................…...[1]
(ii) What will happen if the line 5 is missing?……….…………...………………….....……...…...[1]
(b) The program for output even number between 1-10.
1. FOR Counter = 1 TO 10 STEP 2
2. Counter = Counter + 1
3. PRINT Counter
4. NEXT Count
There are three errors in the algorithm.
Locate and describe these errors.
1................................................................................................................................................
..................................................................................................................................................
2 ...............................................................................................................................................
..................................................................................................................................................
3 ...............................................................................................................................................
..............................................................................................................................................[6]
© HEGICT 2024 2210/ P2 / Unit Assessment 01 / Summer 2024
3
8. This section of program code:
1 PRINT "Input a value between 0 and 100 inclusive"
2 INPUT Value
3 WHILE Value < 0 OR Value > 100
4 PRINT "Invalid value, try again"
5 INPUT Value
6 ENDWHILE
Paper | 2
7 PRINT "Accepted: ", Value
(b) Complete the trace table for this program code using the test data: 200,300,–1,50,60
Value OUTPUT
[5]
(c) Draw a flowchart to represent this section of the above program code.
……………………...……………………………….…………………….……….…….…
…………………..……………...……………………………….…………….……….…….
…………………..……………...……………………………………………..……….…….
……………………..…..……………...…………………………………………….………
…………………..……………...…………………………………………….……….…….
…………………..……………...…………………………………………….……….…….
…………………..……………...…………………………………………….……….…….
………………………..……………...…………………………………………….……….
……………………………..……………..………………………………………………[5]
9. (a) Tick (✓) one box to show the named a quantity that does not change its value over a period of time.
A. Logical operator [ ] B. Array [ ] C. Constant [ ] D. iteration [ ] [1]
(b) The following incomplete algorithm is intended to perform a calculation of total temperature in a
month and output the average temperature.
The asterisks below indicate four lines which are incomplete.
01. Total, Average = 0
* FOR Counter
03. Input temp
* Total
05. ENDFOR
* Average
*. Output “Average is:”
Copy and complete the four lines indicated by asterisks.
………………………………………………………...…………………………….……….
………………………………………………………...…………………………….……….
………………………………………………………...…………………………….……….
………………………………………………...……………………………..…………....[4]
© HEGICT 2024 2210/ P2 / Unit Assessment 01 / Summer 2024