Atomic Type Names
- INTEGER: Whole numbers.
- REAL: Numbers with fractional parts.
- CHAR: A single character.
- STRING: A sequence of zero or more characters.
- BOOLEAN: Logical values `TRUE` or `FALSE`.
- DATE: A valid calendar date.
Literals
- Integer: Written in denary, e.g. `9`, `-3`.
- Real: Must have digits on both sides of the decimal, e.g. `4.7`, `-3.0`.
- Char: Single character in single quotes, e.g. `'x'`, `'C'`, `'@'`.
- String: Enclosed in double quotes, e.g. `"This is a string"`, `""`.
- Boolean: `TRUE`, `FALSE`.
- Date: Format `dd/mm/yyyy`. Best practice: explicitly state type `DATE` and explain format.
Identifiers
- Names for variables, constants, procedures, and functions.
- Written in mixed case (camelCase or PascalCase).
- Rules:
- Must start with a letter.
- Can contain letters (A–Z, a–z) and digits (0–9).
- No underscores, accented letters, or special characters.
- Single letters may be used for array indices or coordinates.
- Case insensitive: e.g. `CountDown` and `Countdown` should not be separate variables.
Variable Declarations
```
DECLARE <identifier> : <data type>
Constants
- Declared at the beginning of pseudocode (unless scope restriction is needed).
CONSTANT <identifier> = <value>
- Only literals can be used as constant values.
- Cannot assign variables, other constants, or expressions.
Assignments
- Assignment operator: `<--`
<identifier> <-- <value>
- Identifier must be a variable.
- Value must evaluate to the same data type as the variable.
No comments:
Post a Comment