Inputs & Outputs
Computer Science: OCR A Level, topic 6.2.1
Thinking Ahead
Problem-solving in computer science involves planning for inputs, outputs, and conditions, using tools like caching and reusable components.

Identifying inputs and outputs
- When solving a problem in computer science, it is important to first identify what goes into the system and what comes out.
- Inputs are the data that the program receives.
- Outputs are the results that the program produces.
- In a simple calculator program, the inputs would be numbers and operations like addition or subtraction.
- The outputs would be the results of these calculations.

Determining preconditions
- Preconditions are the conditions that need to be true before a program or algorithm can run correctly.
- These are important because they help ensure that the program works as expected.
- In a program that divides two numbers, a precondition might be that the second number (the divisor) cannot be zero.
- Without this check, the program could crash or give incorrect results.

Caching
- Caching is a technique used to speed up computer processes by storing frequently accessed data in a faster memory location.
- This can reduce the time it takes to retrieve data from a slower storage medium, such as a hard drive.
- A good example of caching is web browsers storing parts of a webpage so that when the user revisits the page, it loads faster.
- The drawback of caching is that the stored data can become outdated, leading to incorrect results if the data is not refreshed.

Reusable program components
- Reusable program components are parts of a program that can be used in multiple places without rewriting the code.
- These components make coding more efficient and reduce errors because programmers can rely on tried and tested code.
- A function that calculates the area of a rectangle could be reused whenever this calculation is needed.
- This saves time and ensures consistency.
Test yourself on Inputs & Outputs
What is the main purpose of identifying inputs and outputs in a computer program?