What are the basic data types in pseudocode and their descriptions?
INTEGER: A whole number.
REAL: A number capable of containing a fractional part.
CHAR: A single character.
STRING: A sequence of zero or more characters.
BOOLEAN: The logical values TRUE and FALSE.
DATE: A valid calendar date.
How are literals of the basic data types written in pseudocode?
Integer: Written in the denary system, e.g., 5, -3.
Real: Written with at least one digit on either side of the decimal point, e.g., 4.7, 0.3, -4.0.
Char: A single character delimited by single quotes, e.g., 'x', 'C'.
String: Delimited by double quotes, e.g., "This is a string", "" (empty string).
Boolean: TRUE, FALSE.
Date: Typically written as dd/mm/yyyy and explicitly declared as DATE with an explanation of the format.
What rules apply to naming identifiers in pseudocode?
How should variables be declared in pseudocode?
DECLARE <identifier> : <data type>
Example:
DECLARE Counter : INTEGER DECLARE TotalToPay : REAL DECLARE GameOver : BOOLEAN
Why is it good practice to explicitly declare variables in pseudocode?
How are Boolean literals written in pseudocode?
As TRUE and FALSE
How should date literals be represented in pseudocode?
dd/mm/yyyyDATEWhy is it good practice to use constants in pseudocode?
How are constants declared in pseudocode?
CONSTANT <identifier> = <value>
Example:
CONSTANT HourlyRate = 6.50 CONSTANT DefaultText = "N/A"
Only literals can be used as the value of a constant in pseudocode. Variables, other constants, or expressions must not be used.
What is the assignment operator in pseudocode?
←
How are assignments made in pseudocode?
<identifier> ← <value>
Examples:
Counter ← 0 Counter ← Counter + 1 TotalToPay ← NumberOfHours * HourlyRate
How are one-dimensional arrays declared in pseudocode?
DECLARE <identifier>:ARRAY[<lower>:<upper>] OF <data type>
Example:
DECLARE StudentNames : ARRAY[1:30] OF STRING
How are two-dimensional arrays declared in pseudocode?
DECLARE <identifier>:ARRAY[<lower1>:<upper1>,<lower2>:<upper2>] OF <data type>
Example:
DECLARE NoughtsAndCrosses : ARRAY[1:3,1:3] OF CHAR
What is the lower bound of an array, and why should it be explicitly stated?
What can be used as array index values in pseudocode?
Array index values can be:
- Literal values (e.g., 1, 2)
- Expressions that evaluate to valid integers (e.g., n+1)
How do you assign a value to an individual element in a one-dimensional array?
ArrayName[Index] ← <value>
Example:
StudentNames[1] ← "Giorno"
How do you assign a value to an individual element in a two-dimensional array?
ArrayName[Index1, Index2] ← <value>
Example:
NoughtsAndCrosses[2,3] ← ꞌXꞌ
Can arrays be assigned to each other in pseudocode?
Arrays can be assigned to each other if:
- They are of the same size.
- They have the same data type.
SavedGame ← NoughtsAndCrosses
Why should a group of array elements not be accessed individually in a statement?
StudentNames[1 TO 30] ← "" // correct but no marks
FOR Index ← 1 TO 30
StudentNames[Index] ← ""
NEXT IndexHow can you assign a value to a group of array elements?
Use a loop structure:
FOR Index ← <lower> TO <upper>
ArrayName[Index] ← <value>
NEXT IndexExample:
FOR Index ← 1 TO 30
StudentNames[Index] ← ""
NEXT IndexWhat is a user-defined non-composite data type with a list of possible values called?
An enumerated data type
How do you declare an enumerated data type in pseudocode?
TYPE <identifier> = (value1, value2, value3, ...)
Example:
TYPE Season = (Spring, Summer, Autumn, Winter)
What is a user-defined non-composite data type that references a memory location called?
A pointer
How do you declare a pointer type in pseudocode?
TYPE <identifier> = ^<data type>
Example:
TYPE TIntPointer = ^INTEGER TYPE TCharPointer = ^CHAR