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

A Levels Computer Fillable Exam

This document consists of a 14 page exam for Computer Science. It contains 6 questions testing knowledge of programming concepts like variables, arrays, functions, loops, and problem solving. Students are asked to write pseudocode, trace code, find errors, and describe programming terms and best practices.
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)
40 views

A Levels Computer Fillable Exam

This document consists of a 14 page exam for Computer Science. It contains 6 questions testing knowledge of programming concepts like variables, arrays, functions, loops, and problem solving. Students are asked to write pseudocode, trace code, find errors, and describe programming terms and best practices.
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/ 10

Cambridge RATO BANGALA SCHOOL

International Cambridge International Examinations


A Level Cambridge International Advanced Subsidiary and Advanced Level

CANDIDATE
NAME

CENTRE CANDIDATE
NUMBER NUMBER

COMPUTER SCIENCE 9618/22


PAPER 2 Term II Exam,, April 2020
Fundamental Problem-solving and Programming Skills 1:30 hours

Candidates answer on the Question Paper.


No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.


No marks will be awarded for using brand names for software packages or hardware.

At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.

The maximum number of marks is 75

This document consists of 14 printed pages


1 Meena needs to be aware of her average grade and declares a variable AvMark, which
she decides will be a global variable.

(a) State where in the program a global variable is declared.

[1]

(b) Using only global variables is poor programming practice.

Give a possible problem that could result from this.

[1]

(c) Good programming practice uses local variables.

What is the scope of a local variable?

[1]

To make future computation more straightforward Meena retrieves her marks from the file
and stores them in an array, Marks. This array has 30 elements, and marks range from 0
to 100.

(d) State a suitable value to initialise each element of the array. Justify your choice.

Initial value

Reason

[1]

(e) Write pseudocode to declare and initialise the array.

[4]
2 The following algorithm should:
• input ten numbers
• output the largest number input
• output the average value of the input data

10 largest = 0

20 sum = 0

30 for x = 1 to 10

40 input x

50 if x > largest then x = largest

60 output largest

70 sum = sum + x

80 next x

90 average = sum * 10

100 output average

There are four errors in this algorithm.

Locate these errors and suggest a correction.

error 1

correction

error 2

correction

error 3

correction

error 4

correction

[4]
3 Study the following flowchart.

START

count = 1
negcount = 0
poscount = 0
neg = 0
pos = 0
zero = 0

INPUT X

Yes negcount =
is X < 0 ? neg = neg + X negcount + 1

No

Yes poscount =
is X > 0 ? pos = pos + X poscount + 1

No

zero = zero + 1

count = count + 1

Yes
is count <=
10 ?

No

negavge = neg/negcount

posavge = pos/poscount

OUTPUT
negavge, STOP
posavge, zero
(d) Write the pseudocode equivalent of the given flowchart.

.. [7]
4 Gina is developing her programming skills in string handling.
She is going to input two strings.
Each string is made up of three parts:

• letters, followed by
• a single ‘*’ character, followed by
• letters

The groups of letters after the ‘*’ characters are joined together to form a new string which
is then output.

For example, with “DFG*COM” and “B*PUTER” as inputs, the new string output will be
“COMPUTER”.

(a) Write pseudocode to perform this task. (Ensure that you use meaningful variable names and
use proper indentation.

[8]
(b) She writes this code as the function JoinStrings because it is to be used several
times.

(i) State the parameters of the function.

[2]

(ii) Write the function header in the language you used in part (a).

[2]

(iii) State why Gina used a function rather than a procedure.

[1]

(c) A parameter can be passed by value or by reference.

Describe each method.

By value

By reference

[4]
5 Liliane wants to write a program to play chess. She will represent the board of 8 x 8
squares, using the 2-dimensional array Board[8,8].
Each element of the array will need initialising to zero. Later, if a chess piece is on a
square, it will take a value of 1.
She starts by writing pseudocode for the initialisation of a 4 x 4 board. This is easier to
trace.

01 RowNo ← 1
02 WHILE RowNo < 4 DO
03 ColumnNo ← 1
04 WHILE ColumnNo < 4 DO
05 Board[RowNo,ColumnNo] ← 0
06 ColumnNo ← ColumnNo + 1
07 ENDWHILE
08 RowNo ← RowNo + 1
09 ENDWHILE

(a) To test this pseudocode she traces it until the first five elements of Board have been
initialised.

Complete the headings and the trace for these first five elements of the array.

Board
RowNo ColumnNo RowNo<4 ColumnNo<4
[1,1]
1 1 True True 0

[5]
(b) There is an error in the pseudocode.

State the type of error.

[1]

(c) Rewrite two lines that will make the pseudocode work as intended.

Line number Pseudocode

[2]

(d) State the type of loop that would be better for this initialisation. Give an example to show
how it may have been used in the pseudocode

[1]

(e) On a full 8 x 8 board, state the relative positions of the squares Board[1,8] and
Board[8,1] .

[1]
6 A programmer is producing a computer program which allocates seats to customers in
a small theatre.

(a) The code for the program uses variables and constants.

(i) Describe what is meant by a variable.

....... [2]

(ii) State how a constant is different from a variable.

....... [1]

(iii) Describe how using constants can help improve the maintainability of the code.

[2]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy