pseuocode guide Flashcards

1
Q

What are the basic data types in pseudocode and their descriptions?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How are literals of the basic data types written in pseudocode?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What rules apply to naming identifiers in pseudocode?

A
  • Identifiers must start with a letter (A–Z or a–z).
  • Can include letters, digits (0–9), and the underscore (_).
  • Must not contain accented letters.
  • Should not use keywords as identifiers.
  • Case-insensitive (e.g., Counter and counter are treated as the same).
  • Use descriptive names or conventional single letters (e.g., i, j for indices).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How should variables be declared in pseudocode?

A
DECLARE <identifier> : <data type>

Example:

DECLARE Counter : INTEGER  
DECLARE TotalToPay : REAL  
DECLARE GameOver : BOOLEAN  
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it good practice to explicitly declare variables in pseudocode?

A
  • Ensures clarity about the type and purpose of the variable.
  • Helps avoid using undeclared or improperly initialised variables.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are Boolean literals written in pseudocode?

A

As TRUE and FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How should date literals be represented in pseudocode?

A
  • Format: dd/mm/yyyy
  • Explicitly state the data type as DATE
  • Explain the format to avoid confusion due to regional differences
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why is it good practice to use constants in pseudocode?

A
  • Constants make pseudocode more readable as identifiers are often more meaningful than literals.
  • They simplify updates if the constant’s value changes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How are constants declared in pseudocode?

A
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the assignment operator in pseudocode?

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are assignments made in pseudocode?

A
<identifier> ← <value>

Examples:

Counter ← 0
Counter ← Counter + 1
TotalToPay ← NumberOfHours * HourlyRate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are one-dimensional arrays declared in pseudocode?

A
DECLARE <identifier>:ARRAY[<lower>:<upper>] OF <data type>

Example:

DECLARE StudentNames : ARRAY[1:30] OF STRING
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How are two-dimensional arrays declared in pseudocode?

A
DECLARE <identifier>:ARRAY[<lower1>:<upper1>,<lower2>:<upper2>] OF <data type>

Example:

DECLARE NoughtsAndCrosses : ARRAY[1:3,1:3] OF CHAR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the lower bound of an array, and why should it be explicitly stated?

A
  • The lower bound is the index of the first element in an array.
  • It defaults to either 0 or 1 depending on the system, so explicitly stating it ensures clarity. A lower bound of 1 is generally used on pseudocode.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What can be used as array index values in pseudocode?

A

Array index values can be:
- Literal values (e.g., 1, 2)
- Expressions that evaluate to valid integers (e.g., n+1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you assign a value to an individual element in a one-dimensional array?

A
ArrayName[Index] ← <value>

Example:

StudentNames[1] ← "Giorno"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do you assign a value to an individual element in a two-dimensional array?

A
ArrayName[Index1, Index2] ← <value>

Example:

NoughtsAndCrosses[2,3] ← ꞌXꞌ
18
Q

Can arrays be assigned to each other in pseudocode?

A

Arrays can be assigned to each other if:
- They are of the same size.
- They have the same data type.

SavedGame ← NoughtsAndCrosses
19
Q

Why should a group of array elements not be accessed individually in a statement?

A
  • It is not recommended for clarity and efficiency.
    DO NOT:
StudentNames[1 TO 30] ← ""
// correct but no marks
  • Instead, use a loop to iterate over and process the elements individually.
    DO:
FOR Index ← 1 TO 30
    StudentNames[Index] ← ""
NEXT Index
20
Q

How can you assign a value to a group of array elements?

A

Use a loop structure:

FOR Index ← <lower> TO <upper>
    ArrayName[Index] ← <value>
NEXT Index

Example:

FOR Index ← 1 TO 30
    StudentNames[Index] ← ""
NEXT Index
21
Q

What is a user-defined non-composite data type with a list of possible values called?

A

An enumerated data type

22
Q

How do you declare an enumerated data type in pseudocode?

A
TYPE <identifier> = (value1, value2, value3, ...)

Example:

TYPE Season = (Spring, Summer, Autumn, Winter)
23
Q

What is a user-defined non-composite data type that references a memory location called?

24
Q

How do you declare a pointer type in pseudocode?

A
TYPE <identifier> = ^<data type>

Example:

TYPE TIntPointer = ^INTEGER
TYPE TCharPointer = ^CHAR
25
Q

How do you declare a pointer variable?

A

Does not require the caret (^) symbol.

DECLARE <variable> : <pointer type>

Example:

DECLARE MyPointer : TIntPointer
26
Q

What is a composite data type in pseudocode?

A

A collection of data that can consist of different data types, grouped under one identifier.

27
Q

How do you declare a composite data type in pseudocode?

A
TYPE <identifier>
    DECLARE <field1> : <data type>
    DECLARE <field2> : <data type>
    ...
ENDTYPE

Example:

TYPE Student
    DECLARE LastName : STRING
    DECLARE FirstName : STRING
    DECLARE DateOfBirth : DATE
    DECLARE YearGroup : INTEGER
    DECLARE FormGroup : CHAR
ENDTYPE
28
Q

How do you use a composite data type to declare a variable?

A
DECLARE <variable> : <composite type>

Example:

DECLARE Pupil : Student
29
Q

How do you declare variables using user-defined data types?

A
DECLARE <identifier> : <user-defined type>

Examples:

DECLARE Pupil1 : Student
DECLARE ThisSeason : Season
DECLARE MyPointer : TIntPointer
30
Q

How do you access individual items in a user-defined composite data type?

A

Using dot notation.
Example:

Pupil1.LastName ← "Johnson"
Pupil1.YearGroup ← 6
31
Q

Can variables of user-defined data types be assigned to each other?

A

Yes, if they share the same data type.
Example:

Pupil2 ← Pupil1
32
Q

How are arrays of user-defined data types declared and used?

A

Example:

DECLARE Form : ARRAY[1:30] OF Student
Form[Index].YearGroup ← Form[Index].YearGroup + 1
33
Q

How do you input values in pseudocode?

A
INPUT <identifier>

Example:

INPUT Answer
34
Q

How do you output values in pseudocode?

A
OUTPUT <value(s)>

Example:

OUTPUT Score
OUTPUT "You have ", Lives, " lives left"
35
Q

What are the standard arithmetic operators in pseudocode and their functions?

A

+ Addition
- Subtraction
* Multiplication
/ Division (result is REAL)
DIV Integer division (quotient)
MOD Modulus (remainder)

36
Q

What is the precedence of arithmetic operators?

A

Multiplication and division have higher precedence than addition and subtraction. The order of operations be made explicit by using parentheses:

Result ← (A + B) * C
37
Q

What are the relational operators used in pseudocode?

A

> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
= Equal to
<> Not equal to

38
Q

What data type is the result of a relational operation?

39
Q

How can the order of operations in complex relational expressions be clarified?

A

By using parentheses

40
Q

What are the logic operators in pseudocode?