0% found this document useful (0 votes)
3 views8 pages

Homework 20

The document consists of a homework assignment for IGCSE Computer Science that includes programming tasks and questions related to pseudocode, data types, loop structures, and error identification in code. Students are required to locate errors in provided code snippets, explain programming concepts, and suggest improvements. It covers various programming fundamentals necessary for understanding basic coding principles.

Uploaded by

alishahiduk
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)
3 views8 pages

Homework 20

The document consists of a homework assignment for IGCSE Computer Science that includes programming tasks and questions related to pseudocode, data types, loop structures, and error identification in code. Students are required to locate errors in provided code snippets, explain programming concepts, and suggest improvements. It covers various programming fundamentals necessary for understanding basic coding principles.

Uploaded by

alishahiduk
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

1

IGCSE COMPUTER SCIENCE (Homework 20)

Full Name: _________________________

1 Read this section of program code that should input 10 positive numbers and then output
the smallest number input.

1 Small = 0

2 Counter = 0

3 REPEAT

4 INPUT Num

5 IF Num < Small THEN Num = Small

6 Counter = Counter + 1

7 PRINT Small

8 UNTIL Counter < 10

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/21/M/J/15 [Turn over


2

2 Five data types and five data samples are shown below.

Draw a line to link each data type to the correct data sample.

Data type Data sample


Integer 'a'

Real 2

Char 2.0

String True

Boolean "Twelve"
[4]

3 Explain the difference between a variable and a constant in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[2]

4 Identify three different loop structures that you can use when writing pseudocode.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

......................................................................................................................................................[3]

© UCLES 2015 0478/21/M/J/15 [Turn over


3

5 Read this section of program code that should input 30 positive numbers and then output the
largest number input.

1 Large = 9999

2 Counter = 0

3 WHILE Counter > 30

4 DO

5 INPUT Num

6 IF Num < Large THEN Large = Num

7 Counter = Counter - 1

8 ENDWHILE

9 PRINT Large

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/22/M/J/15 [Turn over


4

6 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.

Programming
Example of programming code
concept

Counting Sum = Sum + Value[n]

Repetition IF Value = 10 THEN PRINT 'X'

Selection FOR Counter = 1 TO 10

Totalling Amount = Amount + 1

Sum = Num1 + Num2


[4]

7 REPEAT ... UNTIL is one type of loop structure.

Identify and describe two other types of loop structure that you could use when writing
pseudocode.

Loop structure 1 .........................................................................................................................

Description .................................................................................................................................

...................................................................................................................................................

Loop structure 2 .........................................................................................................................

Description .................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2015 0478/22/M/J/15 [Turn over


5

8 Read this section of program code that inputs 10 positive numbers and then outputs the smallest
number input.

1 Small = 1000
2 Counter = 0
3 REPEAT
4 INPUT Num
5 IF Num < Small THEN Small = Num
6 Counter = Counter + 1
7 UNTIL Counter = 10
8 PRINT Small

(i) Identify three changes you would need to make to find the largest number input instead
of the smallest number.

1 .........................................................................................................................................

...........................................................................................................................................

2 .........................................................................................................................................

...........................................................................................................................................

3 .........................................................................................................................................

.......................................................................................................................................[3]

(ii) Rewrite the program code with your changes.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2016 0478/21/M/J/16 [Turn over


6

9 Read this section of program code that inputs 10 positive numbers and then outputs the total.

1 Total = 0
2 Counter = 0
3 REPEAT
4 INPUT Num
5 Total = Total + Num
6 PRINT Total
7 Counter = Counter + 1
8 UNTIL Counter = 10

This code works, but it is inefficient.

(i) Suggest three improvements that could be made.

1 .................................................................................................................................................

...................................................................................................................................................

2 .................................................................................................................................................

...................................................................................................................................................

3 .................................................................................................................................................

...............................................................................................................................................[3]

(ii) Rewrite the program code with your improvements.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2016 0478/22/M/J/16 [Turn over


7

10 Four statement types and four examples are shown below.

Draw a line to connect each statement type to the correct example.

Statement type Example

Assignment FOR X 1 TO 10

Iteration READ X

Input PRINT X

Output X Y + Z

[3]

11 Identify two different selection statements that you can use when writing pseudocode.

1 ........................................................................................................................................................

..........................................................................................................................................................

2 ........................................................................................................................................................

......................................................................................................................................................[2]

12 Identify two different conditional statements that you can use when writing pseudocode.

1 .......................................................................................................................................................

2 ...................................................................................................................................................[2]

© UCLES 2016 0478/22/M/J/16 [Turn over


8

13 Read this section of program code that should input 50 numbers and then output the average.

1 Total = 0

2 For Counter = 1 TO 50

3 INPUT Num

4 Total = Total + 1

5 Counter = Counter + 1

6 Average = Total/Counter

7 NEXT Counter

8 PRINT Average

There are four errors in this code.

Locate these errors and suggest code corrections to remove each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/21/O/N/15

You might also like