Skip to content

9618 · 11.1

Programming Basics — FAQ

Frequently asked questions for 9618 Programming Basics. Direct answers first, then deeper explanation — then practise with marking.

Why should I use a constant if I can just use a variable?

Using a constant for a value that should not change makes your code safer and more readable. It prevents accidental changes to the value elsewhere in the program. It also makes maintenance easier; if a value like a tax rate changes, you only need to update it in one place (the constant declaration) rather than searching for it throughout your code.

What is the difference between a `CHAR` and a `STRING` of length 1?

Conceptually, a CHAR is for a single character, like 'A', while a STRING is for a sequence of characters, like "Hello". A STRING can have a length of 1, e.g., "A". In many programming languages and in exam pseudocode, they are treated differently. A CHAR variable cannot hold a STRING value, and vice-versa. Always choose the type that best represents the data's purpose.

Do I have to declare variables at the very top of my program?

In Cambridge pseudocode, it is standard practice and highly recommended to declare all variables and constants at the beginning of the program or sub-program. This improves readability and helps you plan your program structure before you start writing the logic. Sticking to this convention will earn you marks for clarity and good programming practice.

Can I store a number like '123' in a STRING variable?

Yes, you can. MyString<"123"MyString <- "123" is a valid assignment. However, the value is stored as text, not as a number. You cannot perform mathematical calculations on it directly (e.g., "123" + 1 is an error). You would need to convert the string to an integer first. This is why choosing the correct data type is so important.