0% found this document useful (0 votes)
5 views

Pseudocode Revision Sheet

The document contains a series of programming exercises and questions related to data types, algorithms, and pseudocode. It includes tasks such as linking data types to samples, explaining programming concepts, and writing algorithms for specific problems. The document is structured in a question-and-answer format with sections for coding examples, loop structures, and data type identification.

Uploaded by

reemoo92009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Pseudocode Revision Sheet

The document contains a series of programming exercises and questions related to data types, algorithms, and pseudocode. It includes tasks such as linking data types to samples, explaining programming concepts, and writing algorithms for specific problems. The document is structured in a question-and-answer format with sections for coding examples, loop structures, and data type identification.

Uploaded by

reemoo92009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

1 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]

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

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

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

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

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

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

a. ..........................................................................................................................................

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

b. ..........................................................................................................................................

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

c. ..........................................................................................................................................

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

Page | 2
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.

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]

Page | 3
5 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
4INPUT Num
5IF Num < Small THEN Small = Num
6Counter = Counter + 1
7 UNTIL Counter = 10
8 PRINT Small

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]

Page | 4
6 A program will be written to store information about members of a swimming
club. The following membership details will be recorded:
Name
Gender
Status:
Senior
Junior
Fee
Team member (Yes or No)

Choose a suitable data type for each of the membership details to be recorded.

Membership details Data type

Name

Gender

Status

Fee

Team member
[5]

Page | 5
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]

Page | 6
8 Read this section of program code that inputs 10 positive numbers and then outputs the total.

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

This code works, but it is inefficient.

Suggest three improvements that could be made.

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

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

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

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

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

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

(ii) Rewrite the program code with your improvements.

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

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

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

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

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

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

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

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

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

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

Page | 7
9 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 FORX 1TO10

Iteration READ X

Input PRINT X

Output X Y+Z

[3]

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

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

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

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

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

Page | 8
11 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]

Page | 9
12 (a) Write an algorithm to input three different numbers, and then output the largest number. Use
either pseudocode or a flowchart.
...................................................................................................................................................

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.
Test data set 1 ...........................................................................................................................

Reason ......................................................................................................................................

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

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

Test data set 2 ...........................................................................................................................

Reason ......................................................................................................................................

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

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

Page | 10
13 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]

Page | 11
.

14 (a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.

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

………...……………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

.……………………………………………………………………………………………………………………..

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

………...……………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………

.…………………………………………………………………………………………………………………[6]

(b) Give one change you could make to your algorithm to ensure initial testing is more
manageable.
...................................................................................................................................................

.............................................................................................................................................. [1]

Page | 12
15 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]

Page | 13
16 (a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends
and the count of positive numbers is output.

(b) Explain the changes you will make to your algorithm to also count the negative numbers.

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

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

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

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

Page | 14
17 An algorithm is written in pseudocode:

INPUT Number
IF Number > 100
THEN OUTPUT ″The number is too large″
ELSE OUTPUT ″The number is acceptable″
ENDIF

(a) Describe the purpose of the algorithm.

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

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

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

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

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

(b) (i) The algorithm only allows one attempt at inputting an acceptable value.

State how you would change the algorithm so that it continues until a suitable input is
supplied.
...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Re-write the algorithm in full, using pseudocode, to implement your answer to part (b)(i).

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

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

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

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

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

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

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

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

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

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

Page | 15
18 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]

19 (a) Give an example of a conditional statement using pseudocode.

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

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

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

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

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

(b) Describe the purpose of a conditional statement.

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

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

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

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

Page | 16
20 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 B+1
NEXT A
CASE A OF
100: B A
200: C A
ENDCASE
IFA>100
THEN
B A
ENDIF
REPEAT
A B*10
UNTIL A > 100
[4]

21 Identify and describe three loop structures that are available in pseudocode.

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

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

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

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

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

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

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

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

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

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

Loop structure 3 ...............................................................................................................................

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

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

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

..........................................................................................................................................................
[6]

Page | 17
22 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.

Array Boolean Char Constant Function Integer

Iteration Procedure Real String Variable

A number with a fractional part that can be positive or negative and used in calculations

Data type ..........................................................................................................................................

A whole number that can be positive, negative or zero and used in calculations

Data type ..........................................................................................................................................

A single number, symbol or letter

Data type ..........................................................................................................................................

A sequence of characters

Data type ..........................................................................................................................................

A data type with two values, True or False

Data type ..........................................................................................................................................


[5]

Page | 18
23 Draw a line to connect each Description to the most appropriate Pseudocode example.

Description Pseudocode example

A loop that will iterate CASE … OF … OTHERWISE … ENDCASE


at least once

A loop that will not be


executed on the first test Number Number + 1
if the condition is false

A conditional statement WHILE … DO … ENDWHILE

Totalling Sum Sum + NewValue

Counting REPEAT … UNTIL

[4]

Page | 19
24 Draw the flowchart symbol for Decision and the flowchart symbol for Process.

Decision Process

[2]

Page | 20

You might also like