Programming – IGCSE Computer Science (0478)

282 questions · page 15 of 19

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
211
0478/23/O/N/19 · Question 4Oct/Nov 2019Paper 235 marks
Loading question…
Question text

4
The following pseudocode algorithm uses nested IF statements.
IF Response = 1
THEN
X + Y
X
ELSE
IF Response = 2
THEN
X – Y
X
ELSE
IF Response = 3
THEN
X * Y
X
ELSE
IF Response = 4
THEN
X / Y
X
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF
(a) Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF
…
… [1]
(b) Re-write the pseudocode algorithm using a CASE statement.
…
…
…
…
…
…
…
…
…
… [4]

212
0478/23/O/N/19 · Question 5Oct/Nov 2019Paper 23146 marks
Loading question…
Question text

5
The algorithm performs an operation on the array named MyData
DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3
0
First
16
Last
FALSE
Found
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
(First + Last) DIV 2
Middle
IF MyData[Middle] = UserIn
THEN
TRUE
Found
ELSE
IF UserIn < MyData[Middle]
THEN
Middle - 1
Last
ELSE
Middle + 1
First
ENDIF
ENDIF
ENDWHILE
OUTPUT Found
This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5
MyData
Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
Value
2
3
5
6
8 10 12 13 14 16 18
20
25
27
29
34
36
(a) Complete the trace table for the input data: 10
First
Last
UserIn
Middle
Found
OUTPUT
[6]
(b) Describe the function being performed by the algorithm.
…
…
…
… [2]

213
0478/11/M/J/19 · Question 7May/June 2019Paper 116 marks
Loading question…
Question text

7
Annie writes a paragraph of text as an answer to an examination question about programming
languages.
Using the list given, complete Annie’s answer by inserting the correct six missing terms. Not all
terms will be used.
•
Assembly
•
Converter
•
Denary
•
Hexadecimal
•
High-level language
•
Low-level language
•
Machine Code
•
Source Code
•
Syntax
•
Translator
The structure of language statements in a computer program is called the
… . A programming language that uses natural
language statements is called a … . When programs
are written in this type of language they need a … to
convert them into … .
A programming language that is written using mnemonic codes is called a
… . An example of this type of language is
… language.
[6]

Advertisement
214
0478/21/M/J/19 · Question 1May/June 2019Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
(i)
State one array you used for Task 1. State the data type and purpose of this array.
Array …
Data type …
Purpose …
…
…
[3]
(ii)
State one variable you used for Task 2 and one variable you used for Task 3. In each
case, state the data type and purpose of the variable.
Task 2 variable name …
Data type …
Purpose …
…
…
Task 3 variable name …
Data type …
Purpose …
…
…
[6]
(b) Write an algorithm to show how you calculated and output the number of late arrivals and the
average number of minutes late for each bus route (part of Task 2), using either pseudocode,
programming statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

215
0478/21/M/J/19 · Question 2May/June 2019Paper 216 marks
Loading question…
Question text

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.
Char
…
…
…
String
…
…
…
Boolean
…
…
…
[6]

216
0478/22/M/J/19 · Question 1May/June 2019Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
Describe the data structures you have used in Task 1 to record the items for sale. Include
some sample data for each data structure you have described.
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how your program for Task 1 ensures the item number is unique.
…
…
…
… [2]
(c) Write an algorithm for the part of Task 2 that allows the buyer to add a new bid, using
either pseudocode, programming statements or a flowchart. Assume that Task 1 has been
completed and that the item details have already been found.
…
…
…
…
…
…
…
…
…

217
0478/22/M/J/19 · Question 2May/June 2019Paper 228 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.
1
Count
INPUT Number
Number
High
Count
Low
REPEAT
INPUT Number
IF Number > High
THEN
Number
High
ENDIF
IF Number > Low
THEN
Number
Low
ENDIF
Count + 1
Count
UNTIL Count > 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low
Find 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]
(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.
…
…
…
…
…
…
…
… [4]

218
0478/22/M/J/19 · Question 4May/June 2019Paper 224 marks
Loading question…
Question text

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.
Statements
Selection
Repetition
FOR A
1 TO 100
B + 1
B
NEXT A
CASE A OF
100: B
A
A
200: C
ENDCASE
IF A > 100
THEN
A
B
ENDIF
REPEAT
A
B * 10
UNTIL A > 100
[4]

Advertisement
219
0478/23/M/J/19 · Question 1May/June 2019Paper 2320 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
Describe the data structures you have used in Task 1 to record the items available that day.
Include some sample data for each data structure you have described.
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how your program for Task 1 ensures all the item codes are different.
…
…
…
… [2]
(c) Explain how your program for Task 2 highlights items where the stock level is low.
…
…
…
…
…
… [3]
(d) Write an algorithm for Task 2 using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed and the list of items currently available
has already been displayed.
…
…
…

220
0478/23/M/J/19 · Question 2May/June 2019Paper 238 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input the weight of 500 items and reject any
that are over-weight or under-weight, then print the percentage rejected.
1
Count
0
Reject
62
Over
58
Under
REPEAT
INPUT ItemWeight
IF ItemWeight > Over AND ItemWeight < Under
THEN
Reject - 1
Reject
ENDIF
Count + 1
Count
UNTIL Count > = 500
Reject / 100
Reject
PRINT "Percentage rejected is ", Reject
Find 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]
(b) Describe how you would change the corrected algorithm to calculate the number accepted
instead of rejected, using a variable Accept, and print a warning if fewer than 50% are
accepted.
…
…
…
…
…
…
…

221
0478/22/F/M/19 · Question 1Feb/March 2019Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
State one constant and one variable that you could have used for Task 1. Give the value that
would be assigned to the constant. Give the data type for the variable. Explain what each one
could be used for.
Constant name …
Value …
Use …
…
Variable name …
Data type …
Use …
…
[6]
(b) Explain how you would need to change your program for Task 1 if there were three bases to
choose from (thick, thin and extra crispy).
…
…
…
… [2]
(c) (i)
Write an algorithm for choosing the additional toppings in Task 1, using either
pseudocode, programming statements or a flowchart. Your algorithm must only include
this part of Task 1.
…
…
…
…
…
…
…
…
…
…
…
…

222
0478/22/F/M/19 · Question 2Feb/March 2019Paper 226 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 50 numbers and total only the positive
numbers.
←
1
Count
←
Count
Total
REPEAT
INPUT Number
IF Number <> 0
THEN
←
Total + Count
Total
ENDIF
←
Count + 1
Count
UNTIL Count < 50
PRINT Total
Find 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]
(b) Show how you would change the corrected algorithm to only total numbers greater than 0
and less than 20.
…
…
… [2]
Question 3 starts on page 10.

223
0478/22/F/M/19 · Question 4Feb/March 2019Paper 224 marks
Loading question…
Question text

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.
Statements
Selection
Repetition
← 1 TO 10
FOR X
← SUM + 1
SUM
NEXT X
WHILE X > 10 DO
←
SUM
SUM + 1
←
X - 1
X
ENDWHILE
IF X > 10
THEN
←
SUM + 1
SUM
←
X - 1
X
ENDIF
REPEAT
←
SUM
SUM + 1
←
X - 1
X
UNTIL X > 10
[4]

Advertisement
224
0478/21/O/N/18 · Question 1Oct/Nov 2018Paper 2120 marks
Loading question…
Question text

1
(a) All arrays, variables, constants and other identifiers should have meaningful names.
(i)
State the name, data type and use of two arrays you created for Task 1.
Array 1 name …
Data type …
Use …
…
Array 2 name …
Data type …
Use …
…
[4]
(ii)
State the name, data type and use of two variables you have created for Task 2.
Variable 1 name …
Data type …
Use …
…
Variable 2 name …
Data type …
Use …
…
[4]
(b) Write an algorithm to enter each item code and quantity. Then when the order is completely
entered, generate a unique order code (part of Task 2), using either pseudocode,
programming statements or a flowchart. You should assume that Task 1 has already been
completed.
…
…
…
…
…
…
…
…
…

225
0478/21/O/N/18 · Question 2Oct/Nov 2018Paper 215 marks
Loading question…
Question text

2
Six terms associated with programming and six descriptions are listed.
Draw a line to link each term with its most appropriate description.
Term
Description
Pre-written code to include in
Top-down design
your own program to carry out
a common task.
Shows the steps representing
an algorithm using various
Structure diagram
shapes of boxes.
Shows the hierarchy of the
different components which
Flowchart
make up a system.
Shows the values of variables
as you manually test your
Pseudocode
program.
Breaks down a system into
Library routine
successively smaller pieces.
Describes a program using a
Trace table
simplified high-level notation.
[5]

Advertisement