Identifiers in Pascal case (7c)

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

Identifiers in Pascal case (7c)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which is a correctly written identifier in Pascal case?
A NumberOfPlayers
B number_of_players
2. Which identifier follows the rule of using only letters and digits?
A TotalScore2
B Total Score
3. Which identifier starts correctly?
A 1Player
B Player1
4. Which identifier has a name that describes its purpose?
A Thing
B AverageMark
5. An array index loop uses a single letter. Which is allowed?
A i
B x_1

Match the Pairs

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

Left columnRight column
1NumberOfPlayers AA correct Pascal case identifier: each word starts with a capital letter, with no spaces or underscores
2Total2 BThe name contains an underscore. Identifiers may only use letters and digits, so it should be PlayerScore.
3A name that describes its purpose, so the reader knows what the variable stores CDECLARE AverageMark : REAL
4Single letters such as i and j are allowed as array indices DA valid identifier: it starts with a capital letter and uses only letters and digits
5DECLARE Player_Score : INTEGER EThe name starts with a digit. An identifier must start with a letter, for example SecondPlace.
6DECLARE 2ndPlace : INTEGER FFOR i ← 1 TO 10

Definitions

NumberOfPlayers

Fill in the Blanks

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

1.
DECLARE NumberOfPlayers : INTEGER _______________ ← 4
2.
_______ TotalScore : INTEGER TotalScore ← 0
3.
DECLARE TotalScore : INTEGER TotalScore ← 0 OUTPUT __________
4.
FOR _ ← 1 TO 10 OUTPUT Marks[i] NEXT i
5.
CONSTANT MaxScore ← 100 DECLARE Score : INTEGER IF Score > ________ THEN

Spot the Error

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

Question 1
A // Count the players
B DECLARE Player_Count : INTEGER
C PlayerCount ← 4
D OUTPUT PlayerCount
Question 2
A DECLARE FinalMark : INTEGER
B DECLARE Mark : INTEGER
C INPUT Mark
D Final Mark ← Mark * 2
Question 3
A CONSTANT PassMark ← 50
B DECLARE 1stMark : INTEGER
C INPUT FirstMark
D IF FirstMark >= PassMark THEN
E OUTPUT "Pass"
F ENDIF
Question 4
A DECLARE Price : REAL
B DECLARE TotalCost : REAL
C INPUT Price
D totalCost ← Price * 3
Question 5
A DECLARE StudentCount : INTEGER
B INPUT StudentCount
C DECLARE A : REAL
D AverageMark ← 0

Answer Key

Identifiers in Pascal case (7c)
Section A: Quick Questions
Q1
A — NumberOfPlayers
Q2
A — TotalScore2
Q3
B — Player1
Q4
B — AverageMark
Q5
A — i
Section B: Match the Pairs
Q1
NumberOfPlayers → A correct Pascal case identifier: each word starts with a capital letter, with no spaces or underscores
Q2
Total2 → A valid identifier: it starts with a capital letter and uses only letters and digits
Q3
A name that describes its purpose, so the reader knows what the variable stores → DECLARE AverageMark : REAL
Q4
Single letters such as i and j are allowed as array indices → FOR i ← 1 TO 10
Q5
DECLARE Player_Score : INTEGER → The name contains an underscore. Identifiers may only use letters and digits, so it should be PlayerScore.
Q6
DECLARE 2ndPlace : INTEGER → The name starts with a digit. An identifier must start with a letter, for example SecondPlace.
Section C: Definitions
Q1
NumberOfPlayers — An identifier in Pascal case: a variable or constant name using only letters and digits, starting with a capital, with each word capitalised and no spaces or underscores.
Section D: Fill in the Blanks
Q1
DECLARE NumberOfPlayers : INTEGER NumberOfPlayers ← 4
Q2
DECLARE TotalScore : INTEGER TotalScore ← 0
Q3
DECLARE TotalScore : INTEGER TotalScore ← 0 OUTPUT TotalScore
Q4
FOR i ← 1 TO 10 OUTPUT Marks[i] NEXT i
Q5
CONSTANT MaxScore ← 100 DECLARE Score : INTEGER IF Score > MaxScore THEN
Section E: Spot the Error
Q1
B — Identifiers may only use letters and digits, so an underscore is not allowed. Pascal case capitalises each word instead: PlayerCount.
Q2
D — An identifier cannot contain a space, so Final Mark is not one name. It should be written FinalMark, matching the declaration.
Q3
B — An identifier cannot start with a digit. It must start with a capital letter, so use a name such as FirstMark.
Q4
D — Pascal case starts with a capital letter. totalCost starts with a lower-case t, so it should be TotalCost, as declared.
Q5
C — Identifiers should describe their purpose. A single letter like A says nothing, and only i and j are allowed as single letters (for array indices). Use AverageMark.