0% found this document useful (0 votes)
11 views9 pages

8.1 Programming Concepts

Uploaded by

sarwannadirkhan
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)
11 views9 pages

8.1 Programming Concepts

Uploaded by

sarwannadirkhan
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
You are on page 1/ 9

Topic: Programming Concepts

2210/24/M/J/22
5 A high-level programming language makes use of arithmetic, Boolean and logical operators.

State how each type of operator is used.


Give an example statement, in pseudocode, for each one.

Arithmetic .........................................................................................................................................

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

Example ...........................................................................................................................................

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

Boolean ............................................................................................................................................

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

Example ............................................................................................................................................

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

Logical ..............................................................................................................................................

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

Example ...........................................................................................................................................

..........................................................................................................................................................
[6]
Answers
Total ← Price * Quantity
IF Age > 18 THEN
IF (Age > 18) AND (Citizen = TRUE) THEN

2210/24/M/J/21
3 State what is meant by the data types integer and real.
Give an example of each.

Integer ..............................................................................................................................................

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

Example ...........................................................................................................................................

Real ..................................................................................................................................................

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

Example ...........................................................................................................................................
[4]
Answers
Count ← 25
Temperature ← 36.7
0478/24/F/M/22

2 (a) Four descriptions and five pseudocode statements are shown.

Draw one line to link each description to its most appropriate pseudocode statement.
Not all pseudocode statements will be used.

Description Pseudocode statement

FOR Count 1 TO 10
a statement to count

Value Value + NewValue

a statement to total
WHILE Value > 10 DO

a statement to start a Value Value + 1


pre-condition loop

REPEAT
a statement to start a
post-condition loop
[4]

Description Pseudocode statement

a statement to count Value ← Value + 1

a statement to total Value ← Value + NewValue

a statement to start a pre-condition loop WHILE Value > 10 DO

a statement to start a post-condition loop REPEAT


4 Describe how variables and constants are used in programming.

Variables hold data that can change while a program runs.


Constants hold data that never changes during the run of the program.
Both have names so they can be referred to in instructions and make code easier to read and maintain.
.................................................................................................................................................... [3]

2210/23/O/N/23

2210/23/O/N/22
5 Explain how variables and constants should be used when creating and running a program.

Variables hold data that can change while a program runs.


Constants hold data that never changes during the run of the program.
Both have names so they can be referred to in instructions and make code easier to read and
maintain.
.................................................................................................................................................... [3]
2210/23/M/J/22
6 State three different features of a high‑level programming language that a programmer could use to
make sure that their program will be easier to understand by another programmer.
Give an example for each feature.

Feature 1 ..........................................................................................................................................

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

Example ...........................................................................................................................................

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

Feature 2 ..........................................................................................................................................

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

Example ...........................................................................................................................................

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

Feature 3 ..........................................................................................................................................

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

Example ...........................................................................................................................................

..........................................................................................................................................................
[6]
Feature 1: Meaningful identifiers
Use descriptive variable and procedure names to show purpose.
Example: TotalMarks ← 0

Feature 2: Indentation and layout


Organise code into blocks to show structure.
Example: Indenting statements inside an IF block.

Feature 3: Comments
Add explanatory notes that do not affect execution.
Example: // Calculate average score

2210/23/M/J/21

2 Tick (✓) one box to show the name of the data structure used to store a collection of data of the same
data type.

A Array
B Constant

C Function

D Variable
[1]

6 State two features that should be included to create a maintainable program. Give

a reason why each feature should be used.

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

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

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

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

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

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

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

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

2210/23/M/J/21 – Q6
1. Use of comments – explains sections of code so future programmers know the purpose.
Reason: helps others understand logic quickly.
2. Modular design / subroutines – split program into procedures or functions.
Reason: each module can be tested or updated separately.

0478/23/F/M/22

6 Describe two types of iteration that a programmer can use whilst writing a program.

Count-controlled (FOR loop) – repeats a set number of times.


Example: FOR x ← 1 TO 10 … NEXT x
Condition-controlled (WHILE/REPEAT loop) – repeats until a condition changes.
Example: WHILE answer <> "yes" DO … ENDWHILE

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

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

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

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

10 A programmer has written a program that will be maintained by another programmer.


Explain how the program can be written to make sure it can be easily maintained by the other
programmer.

Write the program so another programmer can maintain it by:


• Using clear, meaningful variable and procedure names.
• Adding comments to explain the purpose of code blocks.
• Applying consistent indentation and formatting.
• Breaking the program into well-named subroutines/modules.
• Using constants for fixed values.
• Providing documentation of inputs, outputs and algorithm flow.

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

Specimen paper 2B
Pseudocode description Pseudocode statement

a loop that will always iterate at least once REPEAT…UNTIL

a conditional statement to deal with many possible outcomes CASE…OF…OTHERWISE…ENDCASE

a loop that will always iterate a set number of times FOR…TO…NEXT

a conditional statement with different outcomes for true and false IF…THEN…ELSE…ENDIF

Specimen paper 2A
1 Four pseudocode descriptions and five pseudocode statements are shown.

(a) Draw a line to link each pseudocode description to the most appropriate pseudocodestatement.

Some pseudocode statements will not be used.

Pseudocode description Pseudocode statement

FOR…TO…NEXT

a loop that will always iterate at


least once

IF…THEN…ELSE…ENDIF

a loop that will always iterate a set


number of times

CASE…OF…OTHERWISE…ENDCASE

a conditional statement with


different outcomes for true and false

REPEAT…UNTIL

[4]
Pseudocode description Pseudocode statement
a loop that will always iterate at least once REPEAT…UNTIL
a conditional statement to deal with many possible outcomes CASE…OF…OTHERWISE…ENDCASE
a loop that will always iterate a set number of times FOR…TO…NEXT
a conditional statement with different outcomes for true and false IF…THEN…ELSE…ENDIF

(b) Using a single loop, write an algorithm in pseudocode to output 50 names that have been
stored in the array, Name[]

FOR index ← 1 TO 50
OUTPUT Name[index]
NEXT index
FOR index ← 1 TO 50 iterates exactly 50 times.
Name[index] accesses each element of the array Name[] in order.
OUTPUT displays each name.

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

You might also like