Programming Theory
Programming Theory
Computer Science
Programming concepts
Past paper question book
20210228 Edition
[email protected] | 071 11 77 99 0
Table of contents
2015 MJ 21 4 ....................................................................................................................................................... 1
2015 MJ 21 5 ....................................................................................................................................................... 1
2015 MJ 21 6 ....................................................................................................................................................... 1
2015 MJ 22 4 ....................................................................................................................................................... 1
2015 ON 13 4 ...................................................................................................................................................... 2
2016 MJ 21 3 ....................................................................................................................................................... 2
2016 MJ 21 5 ....................................................................................................................................................... 3
2016 MJ 22 4 ....................................................................................................................................................... 3
2016 MJ 22 5 ....................................................................................................................................................... 3
2016 MJ 22 6 ....................................................................................................................................................... 3
2016 ON 22 4 ...................................................................................................................................................... 3
2016 ON 23 4 ...................................................................................................................................................... 4
2016 ON 23 5 ...................................................................................................................................................... 4
2017 MJ 21 3 ....................................................................................................................................................... 4
2017 MJ 21 5 ....................................................................................................................................................... 5
2017 MJ 22 4 ....................................................................................................................................................... 5
2017 ON 22 3 ...................................................................................................................................................... 5
2017 ON 22 4 ...................................................................................................................................................... 6
2017 ON 23 3 ...................................................................................................................................................... 6
2017 ON 23 4 ...................................................................................................................................................... 6
2018 MJ 21 4 ....................................................................................................................................................... 6
2018 MJ 21 5 ....................................................................................................................................................... 7
2018 MJ 22 4 ....................................................................................................................................................... 7
2018 MJ 22 5 ....................................................................................................................................................... 7
2018 ON 22 3 ...................................................................................................................................................... 7
2018 ON 23 4 ...................................................................................................................................................... 8
2018 ON 23 2 ...................................................................................................................................................... 8
2018 ON 23 3 ...................................................................................................................................................... 8
2019 MJ 21 2 ....................................................................................................................................................... 8
2019 MJ 21 3 ....................................................................................................................................................... 8
2019 MJ 21 4 ....................................................................................................................................................... 9
2019 MJ 22 4 ....................................................................................................................................................... 9
2019 MJ 22 5 ....................................................................................................................................................... 9
Programming concepts
2015 MJ 21 4
Five data types and five data samples are shown below. Draw a line to link each data type to
the correct data sample.
[4]
2015 MJ 21 5
Explain the difference between a variable and a constant in a program.
[2]
2015 MJ 21 6
Identify three different loop structures that you can use when writing pseudocode.
[3]
2015 MJ 22 4
Four programming concepts and four examples of programming code are shown below. Draw
a line to link each programming concept to the correct example of programming code.
[4]
1|Page
2015 ON 22 4
A routine checks the weight of melons to be sold in a supermarket. Melons weighing under
0.5 kilograms are rejected and melons weighing over 2 kilograms are also rejected. Give an
example of each type of test data for this routine.
- Normal - Extreme - Abnormal
[3]
2015 ON 22 5
Identify two different conditional statements that you can use when writing pseudocode.
[2]
2015 ON 23 4
A routine checks the age and height of children who are allowed to enter a play area. The
children must be less than 5 years of age and under 1 metre in height.
i. The first set of test data used is age 3 and height 0.82 metres.
i. State what type of test data this is.
ii. Give a reason for using this test data
[2]
ii. Provide two additional sets of test data. For each, give
the type of each set of test data
the reason why it is used
[6]
2016 MJ 21 3
A program will be written to store information about members of a swimming club.
The following membership details will be recorded:
Name
Gender
Status:
o Senior
o Junior
Fee
Team member (Yes or No)
i. Choose a suitable data type for each of the membership details to be recorded.
[5]
ii. The swimming club has 50 members. State the data structure that would be most
suitable to use and give a reason for your choice.
[2]
2|Page
2016 MJ 21 5
REPEAT ... UNTIL is one type of loop structure.
Identify and describe two other types of loop structure that you could use when writing
pseudocode.
[4]
2016 MJ 22 4
Four statement types and four examples are shown below. Draw a line to connect each
statement type to the correct example.
[3]
2016 MJ 22 5
A programmer writes a program to store a patient’s temperature every hour for a day. State
the data structure that would be most suitable to use and give the reason for your choice.
[2]
2016 MJ 22 6
Identify two different selection statements that you can use when writing pseudocode.
[2]
2016 ON 22 4
IF ... THEN ... ELSE ... ENDIF and CASE ... OF ... OTHERWISE ... ENDCASE are two different
conditional statements that you can use when writing pseudocode. Explain, using examples,
why you would choose to use each conditional statement.
[6]
3|Page
2016 ON 23 4
Four validation checks and four descriptions are shown below. Draw a line to link each
validation check to the correct description.
[3]
2016 ON 23 5
REPEAT ... UNTIL and WHILE ... DO ... ENDWHILE are two different loop structures you can use
when writing pseudocode.
Explain, using examples, why you would choose to use each type of loop.
[6]
2017 MJ 21 3
A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will
then output directions to the destination in the form of either a visual map or a list of
directions.
A satellite navigation system is an example of a computer system that is made up of sub-
systems. This structure diagram shows some of its sub-systems.
Complete the diagram by filling in the empty boxes.
[2]
4|Page
2017 MJ 21 5
a. Describe the purpose of each statement in this algorithm.
[2]
b. Identify, using pseudocode, another loop structure that the algorithm in part (a) could
have used.
[1]
c. Write an algorithm, using pseudocode, to input a number between 0 and 100
inclusive. The algorithm should prompt for the input and output an error message if
the number is outside this range.
[3]
2017 MJ 22 4
An algorithm has been written in pseudocode to input 100 numbers and print out the sum. A
REPEAT … UNTIL loop has been used.
2017 ON 22 3
The following diagram shows four data structures and four descriptions. Draw a line to
connect each data structure to the correct description.
[3]
5|Page
2017 ON 22 4
IF … THEN … ELSE … ENDIF is one type of conditional statement used when writing
pseudocode.
Identify and describe another type of conditional statement that you could use when writing
pseudocode. Give a reason why you would use this type of conditional statement.
[4]
2017 ON 23 3
a. There are four lines of code that contain errors. State the line number for each error
and write the correct code for that line.
[2]
b. There are four lines of code that contain errors. State the line number for each error
and write the correct code for that line.
[2]
c. Explain what is meant by the term library routine.
[2]
2017 ON 23 4
Four pseudocode descriptions and five pseudocode statements are shown. Draw one line to
link each pseudocode description to the correct pseudocode statement. Not all pseudocode
statements will be used.
[4]
2018 MJ 21 4
Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.
10.00 9.99 ten
Explain why each value was chosen.
[3]
6|Page
2018 MJ 21 5
Explain the difference between the programming concepts of counting and totalling. Include
an example of a programming statement for each concept in your explanation.
[4]
2018 MJ 22 4
A programmer has written a routine to store the name, email address and password of a
contributor to a website’s discussion group.
a. The programmer has chosen to verify the name, email address and password. Explain
why verification was chosen and describe how the programmer would verify this data.
[4]
b. The programmer has also decided to validate the email address and the password.
Describe validation checks that could be used.
[2]
2018 MJ 22 5
A program checks that the weight of a basket of fruit is over 1.00 kilograms and under 1.10
kilograms. Weights are recorded to an accuracy of two decimal places and any weight not in
this form has already been rejected.
Give three weights as test data and for each weight state a reason for choosing it. All your
reasons must be different.
[3]
2018 ON 22 3
Four programming concepts and four descriptions are shown. Draw a line to connect each
programming concept to the most appropriate description.
[3]
7|Page
2018 ON 23 4
A programmer wants to test that the readings from 2000 electricity meters are greater than
400 units and less than 900 units. The programmer uses selection and repetition statements
as part of the program.
Explain, using programming statements, how selection and repetition could be used in this
program.
[4]
2018 ON 23 2
Describe and give an example for each, the following data types used in programming.
a. Integer
b. String
[4]
2018 ON 23 3
Give an example of a pseudocode statement or statements to perform each of the following
functions.
a. A condition-controlled loop
b. A conditional statement
c. Totalling
[3]
2019 MJ 21 2
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. Each example must be different.
i. Char
ii. String
iii. Boolean
[6]
2019 MJ 21 3
a. Give an example of a conditional statement using pseudocode.
[2]
b. Describe the purpose of a conditional statement.
[2]
8|Page
2019 MJ 21 4
This section of program code may be used as a validation check.
[3]
d. Draw a flowchart to represent this section of program code.
[5]
2019 MJ 22 4
For each of the four groups of statements in the table, place a tick in the correct column to
show whether it is an example of Selection or Repetition.
[4]
2019 MJ 22 5
Explain what is meant by validation and verification. Give an example for each one.
[6]
9|Page
2019 ON 22 5
Four validation checks and four descriptions are shown. Draw a line to connect each validation
check to the correct description.
[3]
2019 ON 22 6
A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the
weight and counting the number of baskets. The total weight is stored in a variable Total and
the number of baskets is stored in a variable BasketCount. Explain, including examples of
programming statements, how totalling and counting could be used in this program.
[4]
2019 ON 22 7
Explain why constants, variables and arrays are used in programming.
[6]
2019 ON 23 2
Describe the use of a subroutine in a program.
[2]
2019 ON 23 3
Name the three types of loop structure used in pseudocode.
[3]
2019 ON 23 6
Draw four different flowchart symbols and describe how they are used in a program
flowchart.
[4]
10 | P a g e
2020 MJ 21 2
State if the statement about structure diagrams is true or false.
[2]
2020 MJ 21 3
Programs can perform validation and verification checks when data is entered.
a. Give the names of two different validation checks and state the purpose of each one.
[4]
b. Give the name of one verification check.
[1]
c. Describe the difference between validation and verification.
[2]
2020 MJ 22 2
Most programming languages include basic data types. Ahmad is describing the basic data
types he has used. State the data type that Ahmad is describing in each sentence. Choose the
data type from this list of programming terms.
i. A number with a fractional part that can be positive or negative and used in
calculations
ii. A whole number that can be positive, negative or zero and used in calculations
iii. A single number, symbol or letter
iv. A sequence of characters
v. A data type with two values, True or False
[5]
11 | P a g e
2020 MJ 22 5
Arrays are data structures used in programming. Explain what is meant by the terms
dimension and index in an array. Use examples of arrays in your explanations.
i. Dimension
ii. Index
[3]
2020 ON 22 2
State if the statement about subroutines is true or false.
i. A subroutine is called from within a program.
ii. A subroutine is not a complete program.
iii. A subroutine is a self-contained piece of code.
iv. A subroutine must return a value to the code from which it was called.
[2]
2020 ON 22 3
This pseudocode algorithm is used as a validation check.
Identify three different types of test data. For each type, give an example of the test data you
would use to test this algorithm and state a reason for your choice of test.
[6]
2020 ON 22 4
This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.
Extend and re-write the algorithm using pseudocode to also count and output how many of
the numbers stored in the array are greater than 500, using the variable Higher. Only output
Higher once with an appropriate message.
[6]
12 | P a g e
2020 ON 22 6
Draw a flowchart symbol to represent each of the following.
i. Input/output
ii. Decision
[2]
2020 ON 23 3
Four programming concepts and five descriptions are shown. Draw a line to connect each
Programming concept to its correct Description. Not all Descriptions will be connected to a
Programming concept.
[4]
13 | P a g e