Programming – IGCSE Computer Science (0478)

282 questions · page 16 of 19

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
226
0478/21/O/N/18 · Question 5Oct/Nov 2018Paper 215 marks
Loading question…
Question text

5
The flowchart performs a mathematical process on a number input called TestNum
DIV is used to represent integer division e.g. 7 DIV 3 = 2
START
Flag
True
INPUT
TestNum
Num
TestNum – 1
Yes
No
Is Num =
1 ?
Num
Num – 1
Is TestNum /
Yes
No
Flag
False
Num = TestNum
DIV Num ?
Yes
Is Flag =
True ?
No
OUTPUT
TestNum
END
(a) Complete the trace table for the input data: 7
Flag
TestNum
Num
OUTPUT
[2]
(b) Complete the trace table for the input data: 6
Flag
TestNum
Num
OUTPUT
[2]
(c) State the purpose of the algorithm in the flowchart.
…
… [1]

227
0478/22/O/N/18 · Question 1Oct/Nov 2018Paper 2220 marks
Loading question…
Question text

1
(a) All variables, arrays, constants and other identifiers should have meaningful names.
(i)
State the name of one variable you have used for Task 3.
Give the data type for the variable. State what it is used for.
Variable name …
Data type …
Use …
[3]
(ii)
Describe the arrays that you have used to store the data for the children in Task 1.
Include the name, data type and its use for each array.
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how you ensured that each identification number entered in Task 1 was unique and
included a correct check digit.
…
…
…
…
…
…
…
… [4]
(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. You should assume that Task 1 has already been completed.
…
…
…

228
0478/22/O/N/18 · Question 3Oct/Nov 2018Paper 223 marks
Loading question…
Question text

3
Four programming concepts and four descriptions are shown.
Draw a line to connect each programming concept to the most appropriate description.
Programming concept
Description
A subroutine that does not
Library routine
have to return a value.
Structure
A standard subroutine that is
diagram
available for immediate use.
A subroutine that always
Procedure
returns a value.
An overview of a program or
Function
subroutine.
[3]

Advertisement
229
0478/22/O/N/18 · Question 4Oct/Nov 2018Paper 224 marks
Loading question…
Question text

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.
Selection …
…
…
…
…
Repetition …
…
…
…
…
…
…
…
[4]

230
0478/23/O/N/18 · Question 1Oct/Nov 2018Paper 2320 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 three arrays you have created for Task 1.
Array 1 name …
Data type …
Use …
…
Array 2 name …
Data type …
Use …
…
Array 3 name …
Data type …
Use …
…
[6]
(ii)
State the name, data type and use for one variable you used in Task 2.
Variable name …
Data type …
Use …
…
[2]
(b) Write an algorithm to show how your program finds and displays the weeks available for
each log cabin and its capacity (part of Task 2), using either pseudocode, programming
statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

231
0478/23/O/N/18 · Question 2Oct/Nov 2018Paper 234 marks
Loading question…
Question text

2
Describe, giving an example for each, the following data types used in programming.
Integer
Description …
…
Example …
String
Description …
…
Example …
[4]

232
0478/23/O/N/18 · Question 3Oct/Nov 2018Paper 233 marks
Loading question…
Question text

3
Give an example of a pseudocode statement or statements to perform each of the following
functions.
A condition controlled loop …
…
…
A conditional statement …
…
…
Totalling …
…
…
[3]

233
0478/23/O/N/18 · Question 4Oct/Nov 2018Paper 234 marks
Loading question…
Question text

4
This is a section of program code.
1 Total = 100.00
2 PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4
PRINT ′Enter a height in metres′
5
INPUT Height
6
Total = Total + Height
7
PRINT Total / 30
8
Count = Count + 1
9 NEXT Count
(a) There are three errors in this code.
State the line numbers that contain the errors and describe how to correct each error.
Error 1 …
…
…
Error 2 …
…
…
Error 3 …
…
…
[3]
(b) State the purpose of this program.
…
…
… [1]

Advertisement
234
0478/23/O/N/18 · Question 5Oct/Nov 2018Paper 236 marks
Loading question…
Question text

5
The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.
1
Fib
0
Prev2
1
Prev1
INPUT Number
IF Number = 0
0
THEN Fib
ENDIF
WHILE Number > 2
Prev2 + Prev1
Fib
Prev1
Prev2
Fib
Prev1
Number - 1
Number
ENDWHILE
OUTPUT Fib
(a) Complete the trace table for the input data: 7
Fib
Prev2
Prev1
Number
OUTPUT
[4]
(b) Complete the trace table for the input data: 2
Fib
Prev2
Prev1
Number
OUTPUT
[2]

235
0478/21/M/J/18 · Question 1May/June 2018Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
You recorded information for the estimate of the cost of building a computer in Task 1.
Give a data structure that you created for Task 1, its name, data type and use.
Data structure …
Name …
Data type …
Use …
…
[4]
(ii)
Describe the data structures that you have used in Task 2 to record the customer details.
Include sample data in the description.
…
…
…
…
…
…
…
… [4]
(b) Explain how your program for Task 1 produces a unique estimate number.
…
…
…
… [2]
(c) Write an algorithm for part of Task 2 to check that the chosen processor and chosen RAM
are in stock, using either pseudocode, programming statements or a flowchart. Assume that
Task 1 has been completed. Do not check the other components or produce the order.
…
…
…
…
…
…

236
0478/21/M/J/18 · Question 3May/June 2018Paper 218 marks
Loading question…
Question text

3
The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.
1 TO 7
FOR Count
INPUT Number
Number
Digit(Count)
NEXT
(Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6)
Sum
IF MOD(Sum,10) <> 0
DIV(Sum,10)*10 + 10 - Sum
THEN Digit(8)
0
ELSE Digit(8)
ENDIF
OUTPUT "GTIN-8"
1 TO 8
FOR Count
OUTPUT Digit(Count)
NEXT
(a) Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4
Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8)
Sum
OUTPUT
Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1
Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8)
Sum
OUTPUT
[5]
(b) 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.
…
…
…
…
…
…
… [3]
Question 4 starts on page 10.

237
0478/21/M/J/18 · Question 5May/June 2018Paper 214 marks
Loading question…
Question text

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]

238
0478/22/M/J/18 · Question 1May/June 2018Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
State the name, the data type and the use of two variables that you have used in Task 2.
Variable 1 name …
Data type …
Use …
Variable 2 name …
Data type …
Use …
[2]
(ii)
Describe, with the aid of some sample data, the data structures that you have used to
record the data for the cows in Task 1.
…
…
…
…
…
…
…
… [4]
(b) Explain how your program for Task 1 ensures that each 3-digit identity code is unique.
…
…
…
… [2]
(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.
…
…
…
…
…
…
…

Advertisement
239
0478/22/M/J/18 · Question 3May/June 2018Paper 226 marks
Loading question…
Question text

3
This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.
INPUT
Number1, Number2, Sign
WHILE
Number1 <> 0
Number1 + Number2
ENDIF
IF
Sign = '+' THEN Answer
Number1 - Number2
ENDIF
IF
Sign = '-' THEN Answer
Number1 * Number2
ENDIF
IF
Sign = '*' THEN Answer
Number1 / Number2
ENDIF
IF
Sign = '/' THEN Answer
IF
Sign <> '/' AND Sign <> '*' AND Sign <> '-'
AND Sign <> '+'
0
THEN Answer
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE
(a) Complete the trace table for the input data:
*
5, 7, +, 6, 2, –, 4, 3, , 7, 8, ?, 0, 0, /
Number1
Number2
Sign
Answer
OUTPUT
[3]
(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode.
…
…
…
…
…
…
…
…
…
… [3]

240
0478/23/M/J/18 · Question 1May/June 2018Paper 2320 marks
Loading question…
Question text

1
(a) All 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, value and use of two constants you could have created for Task 3.
Constant 1 name …
Value …
Use …
…
Constant 2 name …
Value …
Use …
…
[4]
(b) Write an algorithm to perform the set up and ‘On Entry’ part of Task 1, using either pseudocode,
programming statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

Advertisement