Skip to topic
    ← Back to course topics

    Fundamentals of programming — AQA A-Level Computer Science

    Test yourself on Fundamentals of programming with AQA A-Level practice questions.

    Start free

    7 days Premium · Then free forever · No card, no charge

    Fundamentals of programming explained

    This topic covers the fundamental principles of imperative programming, including data types, control structures, and subroutines.

    Read the full explanation

    It emphasizes the structured approach to program design, the use of meaningful identifiers, and the application of arithmetic, relational, and Boolean operations to solve computational problems.

    What to demonstrate

    1. Correct use of programming constructs: sequence, selection, and iteration.
    2. Appropriate declaration and use of variables and constants.
    3. Correct implementation of subroutines (procedures/functions) with parameters and return values.
    Show all 10 objectives
    1. Effective use of local and global variables.
    2. Correct application of arithmetic, relational, and Boolean operators.
    3. Accurate string manipulation and type conversion.
    4. Correct use of arrays and records.
    5. Implementation of exception handling.
    6. Use of random number generation.
    7. Understanding of structured programming principles and hierarchy charts.

    Fundamentals of programming exam tips

    Quick Revision Summary (Key Takeaway)

    Fundamentals of programming covers the core constructs of programming: variables, constants, data types, sequence, selection, iteration, and subroutines. It also introduces key concepts like arrays, records, file handling, and the use of IDEs, forming the foundation for all programming tasks in AQA A-Level Computer Science.

    Topic Overview

    Fundamentals of programming is the bedrock of computer science. It introduces the essential building blocks that allow you to write instructions for a computer to follow. You will learn about variables and constants, which store data, and the different data types such as integer, real, char, string, and Boolean. Understanding how to manipulate these using operators is crucial for any program.

    The topic also covers the three core control structures: sequence, selection, and iteration. Sequence is the order in which statements execute, selection uses IF and CASE statements to make decisions, and iteration uses loops (FOR, WHILE, REPEAT UNTIL) to repeat blocks of code. These structures are universal across programming languages, so mastering them here will help you in any language you encounter.

    Additionally, you will explore subroutines (procedures and functions), which allow you to break down complex problems into manageable chunks. You'll learn about parameters, return values, and the scope of variables. This modular approach is essential for writing maintainable and efficient code. Finally, you'll be introduced to data structures like arrays and records, and file handling, which are vital for storing and organising data. This topic forms the foundation for all other programming topics in the A-Level, including object-oriented programming and algorithms.

    Key Concepts
    • →Variables and constants: named memory locations that store data; constants do not change value.
    • →Data types: integer, real, char, string, Boolean, and their appropriate uses.
    • →Control structures: sequence, selection (IF, CASE), and iteration (FOR, WHILE, REPEAT UNTIL).
    • →Subroutines: procedures and functions, with parameters and return values.
    • →Arrays and records: storing collections of data; arrays use indices, records use fields.
    Marking Points
    • Correct use of programming constructs: sequence, selection, and iteration.
    • Appropriate declaration and use of variables and constants.
    • Correct implementation of subroutines (procedures/functions) with parameters and return values.
    • Effective use of local and global variables.
    • Correct application of arithmetic, relational, and Boolean operators.
    • Accurate string manipulation and type conversion.
    • Correct use of arrays and records.
    • Implementation of exception handling.
    • Use of random number generation.
    • Understanding of structured programming principles and hierarchy charts.
    Examiner Tips
    • 💡Ensure you are familiar with the specific syntax of your chosen programming language (C#, Java, Python, or VB.Net).
    • 💡Practice hand-tracing algorithms to ensure logic is correct before writing code.
    • 💡Always use meaningful variable names to improve code readability.
    • 💡When designing solutions, use hierarchy charts to plan the modular structure.
    • 💡Be prepared to write, adapt, or extend programs provided in the skeleton code.
    • 💡Always use the correct terminology: 'identifier', 'assignment', 'condition', 'iteration' – this shows the examiner you understand the concepts.
    • 💡When writing pseudocode, keep it consistent with AQA's pseudocode style – use indentation and clear keywords like IF, THEN, ELSE, ENDIF, FOR, WHILE, etc.
    • 💡For 6-mark questions, plan your answer: state the data structures needed, outline the algorithm, and then write the code. This ensures you cover all marks.
    Common Mistakes
    • Confusing local and global variable scope.
    • Incorrect use of definite vs indefinite iteration.
    • Failure to use meaningful identifier names.
    • Misunderstanding the difference between integer and real division.
    • Incorrect handling of array indices (e.g., off-by-one errors).
    • Poor documentation or lack of modular structure in code.
    • Misconception: A WHILE loop always executes at least once. Correction: A WHILE loop checks the condition before the first iteration, so it may execute zero times if the condition is initially false.
    • Misconception: A variable declared inside a subroutine is accessible everywhere in the program. Correction: It is local to that subroutine and cannot be accessed outside it.
    • Misconception: A function and a procedure are the same. Correction: A function returns a value, while a procedure does not.
    Revision Plan
    1. 1Week 1: Focus on variables, constants, data types, and operators. Practice writing simple programs that declare variables and perform calculations.
    2. 2Week 2: Move to selection and iteration. Write programs that use IF statements and loops to solve problems like finding the largest number in a list.
    3. 3Week 3: Study subroutines, parameters, and scope. Convert existing programs into modular versions using procedures and functions.
    4. 4Week 4: Cover arrays, records, and file handling. Practice reading from and writing to files, and manipulating arrays.
    5. 5Week 5: Attempt past paper questions, especially 6-mark programming questions. Review mark schemes to understand how marks are awarded.
    Exam Question Types
    • 📋Multiple-choice questions on data types and control structures – read carefully for keywords like 'always' or 'never'.
    • 📋Short-answer questions asking to define terms like 'variable' or 'subroutine' – give precise definitions with examples.
    • 📋Pseudocode writing tasks – follow AQA pseudocode conventions exactly.
    • 📋6-mark extended questions that require designing and writing a program to solve a problem – plan your answer and include comments.
    Command Word Expectations (AQA)
    Define

    Give the precise meaning of a term. No examples needed, but a clear, concise definition is required.

    Explain

    Give a detailed account of how or why something works. Include reasons and causes, not just a description.

    Write

    Produce a program or pseudocode that solves the given problem. Marks are awarded for correct syntax, logic, and use of appropriate constructs.

    How Students Lose Marks (Examiner Pitfalls)
    Pitfall: Students often confuse the roles of local and global variables, leading to incorrect scope and lifetime explanations.
    ❌ Weak Answer (Loses Marks):A local variable is declared inside a subroutine and can be used anywhere in the program.
    Example improved answer:A local variable is declared within a subroutine and is only accessible within that subroutine. It has a limited lifetime, being created when the subroutine is called and destroyed when it ends. In contrast, a global variable is declared outside all subroutines and can be accessed by any part of the program, persisting for the program's duration.
    Examiner Tip: Always use the terms 'scope' and 'lifetime' explicitly. Give a concrete example of a local variable in a subroutine and a global variable at the top of the program.
    Pitfall: When explaining iteration, students often mix up the three types: FOR, WHILE, and REPEAT UNTIL, especially regarding when the condition is checked.
    ❌ Weak Answer (Loses Marks):A WHILE loop runs a fixed number of times.
    Example improved answer:A FOR loop runs a fixed number of times, using a counter variable. A WHILE loop checks a condition before each iteration, so it may execute zero or more times. A REPEAT UNTIL loop checks the condition after each iteration, so it always executes at least once.
    Examiner Tip: Draw a simple flowchart for each loop type to visualise the difference. Remember: WHILE = pre-test, REPEAT UNTIL = post-test.
    Step-by-Step Worked Solutions

    Question: A program stores the daily temperatures for a week in an array. Write pseudocode to calculate and output the average temperature. The array is called temperatures and contains 7 real numbers.

    1. 1.Step 1: Initialise a variable total to 0.
    2. 2.Step 2: Use a FOR loop to iterate from index 0 to 6, adding each element to total.
    3. 3.Step 3: After the loop, calculate average by dividing total by 7.
    4. 4.Step 4: Output the average.
    Final Answer: total = 0 FOR i = 0 TO 6 total = total + temperatures[i] NEXT i average = total / 7 OUTPUT average

    Question: Explain the difference between a parameter and an argument in a subroutine, and give an example of each.

    1. 1.Step 1: Define a parameter as a variable in the subroutine definition.
    2. 2.Step 2: Define an argument as the actual value passed when the subroutine is called.
    3. 3.Step 3: Provide a concrete example: SUBROUTINE add(a, b) – here a and b are parameters; calling add(3, 5) passes 3 and 5 as arguments.
    Final Answer: A parameter is a placeholder variable listed in the subroutine's definition, while an argument is the actual value supplied when the subroutine is called. For example, in SUBROUTINE add(x, y), x and y are parameters; in add(3, 4), 3 and 4 are arguments.
    Active Recall Memory Test
    What is the difference between a local and a global variable?
    Key Fact: A local variable is declared inside a subroutine and is only accessible there; a global variable is declared outside all subroutines and is accessible throughout the program.
    Name the three types of iteration and describe when each is used.
    Key Fact: FOR loop (fixed number of iterations), WHILE loop (condition checked before, may execute zero times), REPEAT UNTIL (condition checked after, always executes at least once).
    What is the purpose of a function in programming?
    Key Fact: A function is a subroutine that returns a value, allowing you to compute a result and use it in an expression.
    How do you declare an array in pseudocode?
    Key Fact: DECLARE arrayName : ARRAY[1:10] OF INTEGER
    Frequently Asked Questions
    What is the difference between a parameter and an argument?
    A parameter is a variable listed in the subroutine's definition, acting as a placeholder. An argument is the actual value you pass when you call the subroutine. For example, in SUBROUTINE add(a, b), a and b are parameters; in add(3, 4), 3 and 4 are arguments.
    Why do we use subroutines in programming?
    Subroutines help break down a complex problem into smaller, manageable parts. They make code reusable, easier to read, and simpler to debug. By using parameters, you can use the same subroutine with different inputs, reducing duplication.
    What is the difference between a WHILE loop and a FOR loop?
    A FOR loop is used when you know exactly how many times you want to repeat a block of code, using a counter. A WHILE loop is used when you want to repeat until a condition becomes false, and the number of iterations may not be known in advance. A WHILE loop checks the condition before each iteration, so it may run zero times.
    How do I choose the right data type for a variable?
    Think about what the variable will store. Use INTEGER for whole numbers, REAL for decimals, CHAR for a single character, STRING for text, and BOOLEAN for true/false values. For example, a person's age would be INTEGER, a temperature might be REAL, and a flag for whether a user is logged in would be BOOLEAN.
    What is the difference between a procedure and a function?
    A procedure is a subroutine that performs a task but does not return a value. A function is a subroutine that returns a single value. For example, a procedure might display a message, while a function might calculate the square root of a number and return it.
    What is an array and why is it useful?
    An array is a data structure that stores a collection of elements of the same data type, accessed by an index. It is useful because it allows you to store multiple values under one name and easily iterate through them using loops, making code more efficient and organised.