CONSTANT

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

CONSTANT

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly creates a constant in IGCSE pseudocode?
A DECLARE HourlyRate : CONSTANT
B CONSTANT HourlyRate ← 6.50
2. True or false: a constant needs a DECLARE statement before it is used.
A True
B False
3. Which is a valid value to give a constant?
A CONSTANT MaxScore ← 100
B CONSTANT MaxScore ← Total * 2
4. What happens to the value of HourlyRate while the program runs?
A It stays at 6.50 and never changes
B It changes each time the loop repeats
5. Which is the main advantage of using CONSTANT HourlyRate ← 6.50 instead of typing 6.50 in many places?
A You only update the value in one place
B The program runs much faster

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1CONSTANT HourlyRate ← 6.50 ASets MaxScore to the literal 100 with no DECLARE needed, so changing the 100 here updates it everywhere
2CONSTANT MaxScore ← 100 BThe value of a constant must be a literal such as 6.50, not an expression that uses a variable like Hours.
3A constant is given its value using only a literal, not a calculation or an INPUT CCreates a constant called HourlyRate that is set once to 6.50 and never changes while the program runs
4A constant needs no DECLARE, so it is created in a single line that gives it its name and value DCONSTANT VatRate ← 20
5DECLARE HourlyRate : REAL CONSTANT HourlyRate ← 6.50 EA constant does not need a DECLARE line. DECLARE is for variables, so the first line should be removed.
6CONSTANT HourlyRate ← Hours * 6.50 FCONSTANT PassMark ← 50

Definitions

CONSTANT HourlyRate ← 6.50

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
________ HourlyRate ← 6.50
2.
CONSTANT HourlyRate _ 6.50
3.
CONSTANT HourlyRate ← 6.50 Pay ← Hours * __________
4.
CONSTANT MaxMarks ← 100 Percent ← Mark / ________ * 100
5.
CONSTANT HourlyRate ← 6.50 Hours ← 4 Pay ← _____ * HourlyRate

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A DECLARE Hours : INTEGER
B CONSTANT HourlyRate = 6.50
C INPUT Hours
D OUTPUT Hours * HourlyRate
Question 2
A DECLARE CONSTANT VatRate ← 0.2
B DECLARE Price : REAL
C INPUT Price
D OUTPUT Price * VatRate
Question 3
A CONSTANT MaxScore ← 100
B DECLARE Score : INTEGER
C MaxScore ← 85
D OUTPUT Score / MaxScore
Question 4
A CONSTANT Pi ← 3.14
B DECLARE Radius : REAL
C INPUT Radius
D Pi ← Pi * Radius ^ 2
Question 5
A CONSTANT DayRate ← 6.50 * 8
B DECLARE Days : INTEGER
C INPUT Days
D OUTPUT Days * DayRate

Answer Key

CONSTANT
Section A: Quick Questions
Q1
B — CONSTANT HourlyRate ← 6.50
Q2
B — False
Q3
A — CONSTANT MaxScore ← 100
Q4
A — It stays at 6.50 and never changes
Q5
A — You only update the value in one place
Section B: Match the Pairs
Q1
CONSTANT HourlyRate ← 6.50 → Creates a constant called HourlyRate that is set once to 6.50 and never changes while the program runs
Q2
CONSTANT MaxScore ← 100 → Sets MaxScore to the literal 100 with no DECLARE needed, so changing the 100 here updates it everywhere
Q3
A constant is given its value using only a literal, not a calculation or an INPUT → CONSTANT VatRate ← 20
Q4
A constant needs no DECLARE, so it is created in a single line that gives it its name and value → CONSTANT PassMark ← 50
Q5
DECLARE HourlyRate : REAL CONSTANT HourlyRate ← 6.50 → A constant does not need a DECLARE line. DECLARE is for variables, so the first line should be removed.
Q6
CONSTANT HourlyRate ← Hours * 6.50 → The value of a constant must be a literal such as 6.50, not an expression that uses a variable like Hours.
Section C: Definitions
Q1
CONSTANT HourlyRate ← 6.50 — Names a value set once with a literal. It never changes, needs no DECLARE, and can be updated in one place.
Section D: Fill in the Blanks
Q1
CONSTANT HourlyRate ← 6.50
Q2
CONSTANT HourlyRate ← 6.50
Q3
CONSTANT HourlyRate ← 6.50 Pay ← Hours * HourlyRate
Q4
CONSTANT MaxMarks ← 100 Percent ← Mark / MaxMarks * 100
Q5
CONSTANT HourlyRate ← 6.50 Hours ← 4 Pay ← Hours * HourlyRate
Section E: Spot the Error
Q1
B — A constant is given its value with the assignment arrow ←, not =. The line should be CONSTANT HourlyRate ← 6.50.
Q2
A — A constant does not need DECLARE. The CONSTANT statement creates it and gives it its value, so the line should be CONSTANT VatRate ← 0.2.
Q3
C — A constant is set once and never changes, so it cannot be assigned a new value. The line should change the variable: Score ← 85.
Q4
D — This line tries to change the constant Pi, which must never change. It should use Pi in an expression, for example OUTPUT Pi * Radius ^ 2.
Q5
A — A constant must be set using only a literal, not a calculation. It should be CONSTANT DayRate ← 52.