SAM HARRIS TECH REVISION
OCR GCSE CS - 2.2 Programming Fundamentals
2.2 Programming Fundamentals (OCR J277)
2.2.1 Programming Fundamentals
- Variables and Constants: Using identifiers to store data that can change (variables) or stay the same (constants) during execution.
- Assignment: Giving a value to a variable (e.g., x = 5).
- Sequence: The order in which instructions are executed.
- Selection: Using IF/ELSE or SWITCH/CASE statements to make decisions.
- Iteration: Using loops like FOR (count-controlled) and WHILE (condition-controlled).
- Operators: Arithmetic (+, -, *, /, MOD, DIV, ^) and Comparison (==, !=, <, >, <=, >=).
- Boolean Logic: Combining conditions using AND, OR, and NOT.
2.2.2 Data Types
- Integer: Whole numbers (e.g., 10, -5).
- Real (Float): Numbers with decimal points (e.g., 3.14).
- Boolean: True or False values.
- Character: A single letter, number, or symbol.
- String: A sequence of characters (e.g., "Hello World").
- Casting: Converting one data type to another (e.g., converting a string "10" to an integer 10).
2.2.3 Additional Programming Techniques
- String Manipulation: Methods like .length, .upper, .lower, .substring, and concatenation (+).
- File Handling: How to open, read, write, and close external text files.
- Records: Storing related data of different types in a structured way (similar to a row in a database).
- Arrays: Using 1D and 2D arrays to store multiple items of the same data type under one name.
- Subprograms: Using Functions (return a value) and Procedures (do not return a value) to make code modular and reusable.
- Random Number Generation: Using libraries to create unpredictable values.
Related Past Paper Questions
-
Year: 2024
Explain the difference between a variable and a constant.
Mark: [2]
-
Year: 2024
State the data type that would be most appropriate for storing whether a light is switched on or off.
Mark: [1]
-
Year: 2023
A program uses a 1D array named 'scores'. Write an algorithm in pseudocode to output every element in the array.
Mark: [3]
-
Year: 2023
Explain the difference between the 'division' (/) and 'integer division' (DIV) operators.
Mark: [2]
-
Year: 2022
Describe the use of 'parameters' when calling a subroutine.
Mark: [2]
-
Year: 2022
Identify three basic programming constructs used in algorithms.
Mark: [3]
-
Year: 2021
Show the result of the following string manipulation: string1 = "Computer Science" followed by print(string1.substring(0, 8)).
Mark: [1]
-
Year: 2021
Explain what is meant by a 'global variable'.
Mark: [2]
-
Year: 2020
A programmer uses an IF statement. State the name of the programming construct being used.
Mark: [1]
-
Year: Sample Paper
Explain why it is good practice to use subroutines when writing a program.
Mark: [3]