revision
Section 1: Fundamental Concepts & Problem Solving
Question: List the seven steps in program development/solving a problem. Answer: 1. Define the problem. 2. Outline the solution. 3. Develop the outline into an algorithm. 4. Test the algorithm for correctness (desk check). 5. Code the algorithm into a specific programming language. 6. Run the program on the computer. 7. Document and maintain the program.
Question: What are the three approaches (methodologies) to program design? Answer: The three common approaches are procedure-driven (focuses on tasks/functions), event-driven (focuses on actions like mouse clicks), and data-driven (focuses on the analysis and structure of data).
Question: Define the term "Computer Program." Answer: A program is a related series of instructions that, when directed through computer hardware, produce desired results to solve an identified problem.
Question: Why is it important to use meaningful names in programming? Answer: Meaningful names (like sales_tax instead of x) act as transparent identifiers for storage locations, making the code easier to read and maintain for the original programmer and others.
Question: Briefly explain the concept of a "desk check" and its importance. Answer: A desk check involves "walking" through an algorithm on paper using simple test data to simulate computer execution. It is important because it identifies logic errors early before they are coded into a program, saving time and frustration.
Question: Define a "bug" and explain three common types of bugs. Answer: A bug is an error in a program. Three common types are:
Syntax errors: Grammatical mistakes in the code (e.g., missing semicolons) detected at compile time.
Logic errors: Mistakes in the thinking or sequence (e.g., using
+instead of*) that produce wrong results.Run-time errors: Errors that occur during execution (e.g., dividing by zero).
--------------------------------------------------------------------------------
Section 2: Data & Data Structures
Question: Explain the difference between a constant and a variable, and give an example of each. Answer: A variable is a named memory location where the stored value can change while the program runs (e.g., score = 10). A constant is a named value that remains fixed throughout execution (e.g., MAX_MARK = 100).
Question: What is a Boolean variable? Answer: A Boolean variable is an elementary data type that can hold only one of two possible values, typically used like a switch (true or false).
Question: Define the following data structures: record, file, array, and string. Answer:
Record: A group of related data items that describe one thing (e.g., a student's ID and name).
File: A collection of many related records.
Array: A list of items of the same data type stored under one name and accessed using an index.
String: A group of characters treated as a single unit.
Question: List the four most common elementary data items/types. Answer: 1. Integer. 2. Real (floating point). 3. Character. 4. Boolean.
--------------------------------------------------------------------------------
Section 3: Control Structures & Logic
Question: Name and briefly explain the three control structures used to write any program. Answer: 1. Sequence: Instructions executed one after another in order. 2. Selection: Making decisions (IF-THEN-ELSE). 3. Repetition (Iteration): Repeating actions while a condition is true (loops).
Question: Differentiate between the WHILE...DO and the REPEAT...UNTIL loops. Answer: A WHILE...DO loop is a leading-decision loop that tests the condition before execution (may run zero times). A REPEAT...UNTIL is a trailing-decision loop that tests the condition at the end (always runs at least once).
Question: Explain the syntax and functionality of a FOR-loop. Answer: A FOR-loop is a counted loop used when the number of repetitions is known in advance. It automatically handles counter initialisation, condition testing, and updating (incrementing/decrementing).
Question: Using an example, explain the difference between the logical operators AND and OR. Answer: AND requires all conditions to be true (e.g., if age > 18 AND has_id, then enter). OR requires at least one condition to be true (e.g., if is_student OR is_senior, get discount).
--------------------------------------------------------------------------------
Section 4: Problem-Solving Applications (IPO Models)
Question: Create an IPO Model to determine the total cost of coffee beans given the number of bags and cost per bag. Answer:
Input: Number of bags, Cost per bag.
Processing: Calculate total cost = (Number of bags × Cost per bag).
Output: Total cost of coffee beans.
Question: Create an IPO Model to convert miles to kilometers (Miles = Kilometers × 0.621371) for distances between 10 and 50. Answer:
Input: Distances (Miles).
Processing: Calculate Kilometers = (Miles / 0.621371) using a loop for distances between 10 and 50.
Output: Converted distances in Kilometers.
Question: Create an IPO Model for a VAT calculation where VAT is 0% for code 0 and 12.5% for code 1. Answer:
Input: Customer name, item name, purchase amount, VAT code.
Processing: If code is 0, set tax = 0. If code is 1, calculate tax = amount × 0.125. Calculate total = amount + tax.
Output: Customer name, item name, purchase amount, sales tax, total amount due.
Question: Create an IPO Model to determine if a person can vote based on birth year. Answer:
Input: Current year, birth year.
Processing: Calculate age = (Current year - birth year). If age < 18, print "cannot vote", otherwise print "can vote".
Output: Voting eligibility message