Programming fundamentals
CIE A-Level Computer ScienceΒ· Unit 11: ProgrammingΒ· 20 min read
1. Core Translator Terminologyβ βββββ± 5 min
All high-level code must be translated to machine code that a computer can execute. The two most common types of translator tested in CIE 9618 are compilers and interpreters, and their differences are a frequent exam topic.
Compiler
A translator that processes the entire source code program in one go, producing a standalone executable machine code file that can be run independently later.
Example:
A C compiler used to build desktop production software.
Interpreter
A translator that processes source code line-by-line during execution, translating one line at a time and does not produce a permanent executable file.
Example:
An online Python editor that runs code as you type.
State one advantage of using a compiler over an interpreter for commercial software.
- 1
Recall that compilers complete translation once, before any execution.
- 2
Executables produced by compilers run directly on the CPU with no further translation needed.
- 3
Write the answer: Compiled software runs faster than interpreted software because translation only happens once, rather than every time the program is launched.
2. Core Structured Programming Constructsβ βββββ± 6 min
All structured programs are built from just three core control constructs, regardless of the programming language used. Structured programming avoids messy unstructured jumps (like goto statements) and makes code easier to read and debug.
Sequence: Code executes in exactly the order it is written, line by line.
Selection: The program chooses between different blocks of code based on a boolean condition (e.g.
if/else,switchstatements).Iteration: A block of code is repeated multiple times (also called looping, e.g.
forandwhileloops).
What type of core construct is shown in the pseudocode below?
FOR count FROM 1 TO 10
OUTPUT count * count
NEXT count
- 1
Check if the code runs line-by-line with no choices or repetition: that is sequence, so this is not the case.
- 2
Check if the code chooses between code paths based on a condition: that is selection, which does not happen here.
- 3
Check if the code repeats a block multiple times: the
FORloop repeats the output line 10 times. - 4
Conclusion: This is an example of iteration.
3. Syntax vs Semantic (Logic) Errorsβ β ββββ± 7 min
A very common exam question asks you to distinguish between two broad types of error in code. The difference between them is consistently tested in multiple-choice and short-answer questions.
Syntax Error
An error that violates the grammatical rules of the programming language. The translator cannot process the code, so the program will not run at all.
Logic (Semantic) Error
An error where the code follows all language rules (so no syntax error) and runs, but produces the wrong output because the underlying logic of the program is incorrect.
The code below is intended to output Positive if the input number is greater than zero, and Non-positive otherwise. What type of error does it contain?
INPUT number
IF number < 0 THEN
OUTPUT "Positive"
ELSE
OUTPUT "Non-positive"
ENDIF
- 1
First check for syntax violations: all keywords are spelled correctly, the
IFblock is properly formatted, so the code will run. - 2
Test with a sample input: input
5(which is positive). The condition5 < 0is false, so the code outputsNon-positive, which is wrong. - 3
The code runs, but produces the wrong result, so this is a logic (semantic) error.
4. Introduction to Programming Paradigmsβ β ββββ± 6 min
A programming paradigm is a style or approach to programming. CIE 9618 requires you to distinguish between the two most common paradigms: imperative (procedural) and declarative.
Imperative: Code describes how to solve a problem, as a sequence of steps that change program state. Most general-purpose languages like Python, Java and C are imperative.
Declarative: Code describes what result you want, not how to get it. The interpreter works out the steps to produce the result. SQL and HTML are common examples of declarative languages.
Classify the following code as imperative or declarative: SELECT product FROM stock WHERE price > 100;
- 1
Check what the code describes: it states that we want the names of products with price over 100. It does not explain how to search the stock table for these products.
- 2
Recall that declarative code describes what result is needed, not how to get it.
- 3
Conclusion: This is an example of declarative code.
5. Common Pitfalls
Wrong move:
Claiming interpreters produce executable machine code files.
Why:
This is the most common mistake on this topic, and examiners explicitly test this distinction.
Correct move:
Only compilers produce standalone executable machine code; interpreters translate line-by-line during execution and do not save a permanent executable.
Wrong move:
Calling fixed named values variables.
Why:
The definition of a variable requires it to be able to change value during execution, fixed values are constants.
Correct move:
Use the term variable only for mutable named storage; fixed values are called constants.
Wrong move:
Assuming all runtime errors are syntax errors.
Why:
Students often group all errors that stop execution together, but CIE distinguishes error types by their cause.
Correct move:
Syntax errors are caused by broken language rules; runtime errors (like dividing by zero) occur during execution of valid syntax.
Wrong move:
Mixing up selection and iteration in classification questions.
Why:
Students often confuse the two constructs in short answer responses.
Correct move:
Selection = choice between paths, iteration = repetition of a code block.
Wrong move:
Claiming a language can only belong to one paradigm.
Why:
Many modern languages support multiple paradigms, so classification depends on how the code is written.
Correct move:
Classify based on the code example: a step-by-step Python program is imperative, even though Python supports other paradigms.
6. Quick Reference Cheatsheet
Term | Key Definition |
|---|---|
Compiler | Translates full source code once, produces executable |
Interpreter | Translates line-by-line during execution |
Variable | Named mutable memory storage |
Constant | Named fixed memory storage |
Syntax error | Rule violation, prevents program running |
Logic error | Program runs, outputs wrong result |
Sequence | Code executes in written order |
Selection | Chooses code block by condition |
Iteration | Repeats code block multiple times |
Imperative | Tells computer how to solve problem |
Declarative | Tells computer what result to get |
When this came up on past exams
AI-estimated based on syllabus patterns β cross-check with official past papers for accuracy. Use only as revision-focus signals.
- 2022 Β· 1
Compiler vs interpreter distinction
- 2023 Β· 1
Syntax vs logic error identification
- 2021 Β· 2
Core constructs classification
Going deeper
What's Next
Programming fundamentals are the bedrock of all programming work in CIE 9618. Every concept you learned here will be applied repeatedly when you write code, debug problems, and answer exam questions. Core distinctions like compiler vs interpreter and syntax vs logic error are regular topics in Paper 1 multiple-choice, so make sure you memorize these definitions before moving on. Next, you will build on these fundamentals to learn about data types, more advanced control structures, and debugging techniques that you will use for your practical programming work.
