Programming – IGCSE Computer Science (0478)

282 questions · page 18 of 19

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
256
0478/21/M/J/17 · Question 5May/June 2017Paper 216 marks
Loading question…
Question text

5
(a) Describe the purpose of each statement in this algorithm.
1 TO 300
FOR I
INPUT Name[I]
NEXT I
…
…
…
…
… [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]

257
0478/22/M/J/17 · Question 1May/June 2017Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
For a variable that you have used to record information about the cost of the outing in
Task 1, state the name, data type and its use.
Variable name …
Data type …
Use …
[3]
(ii)
State two constants that you could have used for Task 1. Give the value that would be
assigned to each one and explain what it is used for.
Constant 1 name …
Value 1 …
Use 1 …
Constant 2 name …
Value 2 …
Use 2 …
[6]
(b) Explain how you would need to change your calculation in Task 1 if each carer were paid
$20.00 for coming on the outing.
…
…
…
…
…
… [2]
(c) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed. You do not need to produce
the list of people on the outing.
…
…
…
…
…
…
…
…

258
0478/22/M/J/17 · Question 4May/June 2017Paper 225 marks
Loading question…
Question text

4
An algorithm has been written in pseudocode to input 100 numbers and print out the sum.
A REPEAT … UNTIL loop has been used.
Count ← 0
Sum ← 0
REPEAT
INPUT Number
Sum ← Sum + Number
Count ← Count + 1
UNTIL Count > 100
PRINT Sum
(a) Find the error in the pseudocode and suggest a correction.
Error …
Correction …
…
[2]
(b) Rewrite the correct algorithm using a more suitable loop structure.
…
…
…
…
…
…
… [3]

Advertisement
259
0478/12/F/M/17 · Question 6Feb/March 2017Paper 124 marks
Loading question…
Question text

6
The diagram shows five operating system functions and five descriptions.
Draw a line between each operating system function and its description.
Function
Description
Many processes appear to run simultaneously
Interrupt
Data are temporarily held in a buffer waiting for an
Utility
output device to access it
A signal that causes the operating system to take
Memory
a specified action
management
A program that performs a specific task required
Spooling
for the operation of a computer system
A process of assigning blocks of memory to
Multitasking
programs running in a computer
[4]

260
0478/22/F/M/17 · Question 1Feb/March 2017Paper 2220 marks
Loading question…
Question text

1
(a) All variables and other identifiers should have meaningful names.
(i)
Declare the array used to store the reaction times for the whole school.
… [1]
(ii)
Change this declaration so the array can only hold records for a sample of 50 students.
… [1]
(iii)
Explain why an array is an effective data structure for storing the reaction time records.
…
…
…
… [2]
(b) Write an algorithm to complete Task 1 for the whole school, using either pseudocode,
programming statements or a flowchart. DO NOT include any validation routines.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [3]
(c) Identify three different types of test data you used to test the validation checks on the age
input in Task 1. For each type, give an example of appropriate data.
Type of test data
Example data
[6]
(d) Explain how you calculated and outputted the average reaction time based on the user
inputs of age and school house, as part of Task 3. Any programming statements used in your
answer must be fully explaine

261
0478/22/F/M/17 · Question 2Feb/March 2017Paper 224 marks
Loading question…
Question text

2
Read this section of code that inputs the ages of people entering an event. The input sequence is
ended by inputting a negative value for age. The code outputs the number of people at the event
over the age of 18.
01
Num18 = 0
02
INPUT Age
03
WHILE Age >= 0 DO
04
IF Age >= 18 THEN
05
Num18 = Num18 + Age
06
ENDIF
07
ENDWHILE
08
PRINT Num18 - Age
There are four errors in this code.
Locate these errors and suggest code correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]

262
0478/22/F/M/17 · Question 3Feb/March 2017Paper 228 marks
Loading question…
Question text

3
There is a program that stores the following data:
•
EmployeeID, an employee ID which must be two letters followed by 4 numbers, e.g. TY4587
•
Manager, whether the employee is a manager or not
•
AnnualHoliday, number of whole days’ annual holiday
•
PayGrade, the employee’s pay grade which must be a single letter A–F
Complete the following table to identify:
•
The most appropriate data type for each variable
•
An appropriate validation check for each variable. You must use a different validation check
for each variable.
Variable
Data type
Appropriate validation check
EmployeeID
Manager
AnnualHoliday
PayGrade
[8]

263
0478/22/F/M/17 · Question 5Feb/March 2017Paper 228 marks
Loading question…
Question text

5
(a) Rewrite the following pseudocode algorithm using a WHILE … DO … ENDWHILE loop.
INPUT Num
FOR Counter ← 1 TO 12
Num ← Num * Counter
A[Counter] ← Num
NEXT
…
…
…
…
…
…
…
…
…
… [4]
(b) Explain the differences between a WHILE … DO … ENDWHILE and a REPEAT … UNTIL
loop.
…
…
…
…
…
…
…
… [4]

Advertisement
264
0478/12/O/N/16 · Question 2Oct/Nov 2016Paper 124 marks
Loading question…
Question text

2
State four functions of an operating system.
1 …
2 …
3 …
4 …
[4]

265
0478/21/O/N/16 · Question 1Oct/Nov 2016Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
For four of the variables, constants or arrays that you used in Task 1, state the name, data
structure, data type and its use.
Name 1 …
Data structure …
Data type …
Use …
Name 2 …
Data structure …
Data type …
Use …
Name 3 …
Data structure …
Data type …
Use …
Name 4 …
Data structure …
Data type …
Use … [8]
(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed and that there are three
candidates for class captain.
…
…
…
…
…
…
…
…
…

266
0478/21/O/N/16 · Question 2Oct/Nov 2016Paper 218 marks
Loading question…
Question text

2
Read this section of program code that:
•
inputs 10 numbers
•
checks whether each number is within a specified range
•
totals the numbers within the range and outside the range
1
InRange = 0
2
OutRange = 1000
3
FOR Count = 1 TO 10
4
INPUT Num
5
IF Num > 10 AND Num < 20 THEN InRange = InRange + 1
6
ELSE OutRange = OutRange - 1
7
Count = Count + 1
8
NEXT X
9
PRINT InRange, OutRange
(a) There are four errors in this code.
Locate these errors and suggest a correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
… [4]
(b) Decide, with reasons, whether the numbers 10 and 20 are within or outside the range.
Within
Outside
Number
Reason
range (✓)
range (✓)
10
… ..
… ..
20
… ..
… ..
[4]

267
0478/21/O/N/16 · Question 3Oct/Nov 2016Paper 215 marks
Loading question…
Question text

3
The flowchart below inputs the price of an item under $10. The change from a $10 note is output.
Any amount less than 5 cents is rounded up to 5 cents.
The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5
START
INPUT Price
Change
10 – Price
Is
Yes
Change
Dollars
INT(Change)
>= 1?
No
Change
Change – INT(Change)
OUTPUT Dollars,
" dollars"
Is
Yes
Change
Change
Change – 0.5
>= 0.5?
No
OUTPUT "One 50
cent coin"
TenCents
INT(Change * 10 + 0.5)
OUTPUT TenCents,
" ten cent coins"
Is Change*10 –
OUTPUT "One 5
Yes
TenCents
cent coin"
> 0?
No
END
Complete the trace table for the input data: 6.29
Price
Change
Dollars
TenCents
OUTPUT
[5]

268
0478/21/O/N/16 · Question 5Oct/Nov 2016Paper 216 marks
Loading question…
Question text

REPEAT ... UNTIL
WHILE ... DO ... ENDWHILE are two different loop
5
and
structures you can use when writing pseudocode.
Explain, using examples, why you would choose to use each type of loop.
Example 1 …
…
…
…
Reason for choice …
…
…
Example 2 …
…
…
…
Reason for choice …
…
… [6]

Advertisement
269
0478/22/O/N/16 · Question 1Oct/Nov 2016Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
For three of the variables that you have used in Task 1, state the name, type and its use.
Variable 1 name …
Type …
Use …
Variable 2 name …
Type …
Use …
Variable 3 name …
Type …
Use … [3]
(ii)
Name and describe the data structure(s) that you have used to store the donation totals
for each charity. Explain why you chose your data structure(s).
Name of data structure(s) …
Description …
…
Reason …
… [3]
(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed.
…
…
…
…
…
…
…
…
…
…
…
…

270
0478/22/O/N/16 · Question 2Oct/Nov 2016Paper 228 marks
Loading question…
Question text

2
Read this section of program code that inputs positive numbers, discards any negative numbers
and then outputs the average. An input of zero ends the process.
1
Total = 0
2
Counter = 100
3
REPEAT
4
REPEAT
5
INPUT Num
6
UNTIL Num < 0
7
Total = Total + 1
8
Counter = Counter + Num
9
UNTIL Num = 0
10
Average = Total / (Counter - 1)
11
Print Average
There are four errors in this code.
Locate these errors and suggest a correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
… [8]

Advertisement