0% found this document useful (0 votes)
7 views13 pages

Midterm

This document contains a 13 page midterm exam for a computer science course. The exam consists of multiple choice and written answer questions testing knowledge of topics like program development life cycles, data structures, data validation, and pseudocode algorithms. It provides instructions to write name and class, use blue or black pen, and write answers in the provided booklet.

Uploaded by

kouhiimiruku
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
7 views13 pages

Midterm

This document contains a 13 page midterm exam for a computer science course. The exam consists of multiple choice and written answer questions testing knowledge of topics like program development life cycles, data structures, data validation, and pseudocode algorithms. It provides instructions to write name and class, use blue or black pen, and write answers in the provided booklet.

Uploaded by

kouhiimiruku
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 13

13

Computer Science (IB)


Midterm Exam
Total Page: 13 Duration: 105 minutes

Additional Materials: None

READ THESE INSTRUCTIONS FIRST: For examiner’s use only


Question
Mark
1. Write your Chinese name, English name, number
1
and class on all the work you hand in. 2

3
2. Write in dark blue or black pen.
4
3. You may use an HB pencil for any diagrams or graphs. 5
6
4. Do not use staples, paper clips,
7
highlighters, glue or correction fluid. 8
9
5. Dictionaries are NOT allowed.

6. Write all your answers on the Answer Booklet. Total /59

© UCLES 2023 [Turn over


2

1 (a) Four descriptions of stages in the program development life cycle are shown.

Draw one line to link each description to its most appropriate program development life cycle
stage.

Not all program development life cycle stages will be used.

Program development life cycle description Program development life cycle stage

develop an algorithm to solve the problem analysis


by using structure diagrams, flowcharts or
pseudocode

coding

detect and fix the errors in the program


design

identify the problem and its requirements


evaluation

write and implement the instructions to


solve the problem testing
[4]
(b) Identify three of the component parts after a problem has been decomposed.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................
[3]

2 Tick (✓) one box to show the name of the data structure used to store a collection of data of the
same data type.

A Array

B Constant

C Function

D Variable
[1]
© UCLES 2023
13

3 (a) Describe what is meant by data validation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) A validation check is used to make sure that any value that is input is an integer between 30
and 200 inclusive.

Give one example of each type of test data to check that the validation check is working as
intended. Each example of test data must be different.

Give a reason for each of your choices of test data.

Normal test data .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Abnormal test data ...................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Extreme test data .....................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[6]

4 Explain the purpose of the library routines DIV and ROUND

DIV ...................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ROUND ..............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]
© UCLES 2023 [Turn over
4

5 An algorithm has been written in pseudocode to allow some numbers to be input. All the positive
numbers that are input are totalled and this total is output at the end.
An input of 0 stops the algorithm.

01 Exit 1 ←
02 WHILE Exit <> 0 DO
03 INPUT Number
04 IF Number < 0
05 THEN
06 Total ←
Total + Number
07 ELSE
08 IF Number = 0
09 THEN
10 Exit 1 ←
11 ENDIF
12 ENDIF
13 ENDIF
14 OUTPUT "The total value of your numbers is ", Number

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023
5

(b) Describe how you could change the corrected algorithm to record and output how many
positive numbers have been included in the final total.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

6 State two features that should be included to create a maintainable program.

Give a reason why each feature should be used.

1 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2023 [Turn over


6

7 The flowchart represents an algorithm.

START

Pointer 1

INPUT
Letter

IS
Word[Pointer, 1] Pointer Pointer + 1
= Letter ?

Yes

OUTPUT "Letter ", Letter,


" is represented by ",
Word[Pointer, 2]

OUTPUT "Another Letter?


(Y or N)"

INPUT Choice

Yes IS No
Choice = STOP
'Y' ?

© UCLES 2023
7

The table represents the two-dimensional (2D) array Word[] which stores the first half of the
phonetic alphabet used for radio transmission. For example, Word[10,1] is ‘J’.

Index 1 2
1 A Alpha
2 B Bravo
3 C Charlie
4 D Delta
5 E Echo
6 F Foxtrot
7 G Golf
8 H Hotel
9 I India
10 J Juliet
11 K Kilo
12 L Lima
13 M Mike

(a) Complete the trace table for the algorithm by using the input data: F, Y, D, N

Pointer Letter Choice OUTPUT

[4]

© UCLES 2023 [Turn over


8

(b) Identify the type of algorithm used.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Describe one problem that could occur with this algorithm if an invalid character was input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023
9

BLANK PAGE

© UCLES 2023 [Turn over


10

8 The function LENGTH(Phrase)calculates the length of a string Phrase

(a) Write the pseudocode statements to:


• store the string "The beginning is the most important part" in Phrase
• calculate and output the length of the string
• output the string in upper case.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Write the output your pseudocode should produce.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023
11

9 A one-dimensional (1D) array Days[] contains the names of the days of the week. A two-
dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once an
hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.

The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]

The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0 °C to +50.0 °C inclusive.

Write a program that meets the following requirements:


• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9 / 5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.

All inputs and outputs must contain suitable messages.

All data output must be rounded to one decimal place.

You will need to initialise and populate the array Days[] at the start of the program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 [Turn over
12

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023
13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 [Turn over

You might also like