Section A — 1 Mark Questions
1. What is an algorithm? [1 Mark]
Answer: An algorithm is a step-by-step procedure or set of instructions designed to solve a specific problem.
2. Define a flowchart. [1 Mark]
Answer: A flowchart is a graphical or pictorial representation of an algorithm using standard symbols and connecting lines.
3. What shape is used to represent an input/output operation in a flowchart? [1 Mark]
Answer: A parallelogram.
4. What does a diamond-shaped box represent in a flowchart? [1 Mark]
Answer: A decision-making or branching point.
5. Which flowchart symbol is used to indicate the starting or ending point of a process? [1 Mark]
Answer: An oval or terminator symbol.
6. What is the purpose of flow lines in a flowchart? [1 Mark]
Answer: Flow lines indicate the direction of execution and connect different flowchart symbols.
7. What is the primary function of a conditional statement in problem-solving? [1 Mark]
Answer: To make decisions and control the flow of execution based on whether a condition is true or false.
8. What type of control structure is used when a set of instructions needs to be executed repeatedly? [1 Mark]
Answer: A looping or iteration structure.
9. What is an array? [1 Mark]
Answer: An array is a collection of elements of the same data type stored at contiguous memory locations.
10. How is the first element of an array typically indexed in programming? [1 Mark]
Answer: It is typically indexed at zero (0).
11. State the purpose of the if-then statement. [1 Mark]
Answer: It executes a specific block of code only when a given condition evaluates to true.
12. What is nested if-then-else? [1 Mark]
Answer: It is an if-then-else statement placed inside another if or else block to handle multiple conditions.
13. What is the role of a loop counter? [1 Mark]
Answer: To keep track of the number of times a loop has been executed.
14. Give another name for an iterative control structure. [1 Mark]
Answer: A loop.
15. What does the repeat-while loop structure check? [1 Mark]
Answer: It checks a condition to determine whether the loop should continue running or terminate.
16. Why are comments useful in algorithms? [1 Mark]
Answer: They help explain the logic and make the algorithm easier for humans to understand.
17. What is the term for a logical error where a loop never terminates? [1 Mark]
Answer: An infinite loop.
18. What is the maximum number of paths that can emerge from a standard decision box in a flowchart? [1 Mark]
Answer: Two paths (usually labeled True and False).
19. Define problem-solving in the context of computer programming. [1 Mark]
Answer: The process of identifying a problem, designing a logical solution, and implementing it as a computer program.
20. What is the index of the last element in an array of size n? [1 Mark]
Answer: n - 1
Section B — 2/3 Mark Questions
1. Differentiate between an algorithm and a flowchart. [2 Marks]
Answer: An algorithm is a step-by-step textual description of a solution written in natural language or pseudocode, whereas a flowchart is a visual or graphical representation of the same logic using standard geometric symbols. While algorithms focus on logical instructions, flowcharts highlight the flow of control and direction of execution.
2. Explain the purpose of the rectangular process box in flowcharts with an example. [2 Marks]
Answer: The rectangular box is used to represent data transformation, calculations, or assignment operations in a flowchart. For example, assigning the result of an arithmetic operation like setting a value using C = A + B is enclosed in a rectangle.
3. Describe the basic working of a single if-then-else control structure. [2 Marks]
Answer: The if-then-else structure evaluates a given condition. If the condition evaluates to true, the statements inside the if block are executed. If the condition evaluates to false, the alternative set of statements inside the else block is executed instead.
4. What is a nested if-then-else statement? Give a brief scenario where it is used. [3 Marks]
Answer: A nested if-then-else statement occurs when an entire if-then-else construct is placed inside another if block or else block. It is used when a decision depends on multiple sequential conditions. For example, assigning letter grades based on student marks (e.g., if marks > 90 grade A, else if marks > 80 grade B) requires nested conditions.
5. Explain the concept of looping using the repeat-while structure. [3 Marks]
Answer: The repeat-while structure is an iterative control statement that executes a block of statements repeatedly as long as a specified condition remains true. The loop checks the condition; if true, the body executes again. Once the condition evaluates to false, the loop terminates and control moves to the next instruction.
6. Why are arrays useful in computer programming? Give two main advantages. [2 Marks]
Answer: Arrays are useful for storing multiple items of data under a single variable name. Two main advantages are that they allow efficient management of large amounts of related data using loops, and they enable direct access to any element using its index.
7. Write a short note on connector symbols in flowcharts. [2 Marks]
Answer: Connector symbols are represented by small circles and are used when a flowchart is too large to fit on a single page or when flow lines cross. They connect different sections of a flowchart across pages or complex layouts using matching letters or numbers inside the circle.
8. State the importance of initialization in iterative algorithms. [2 Marks]
Answer: Initialization ensures that loop control variables and accumulators start with known, correct baseline values before the iteration begins. Without proper initialization, loops may execute with unpredictable garbage values, leading to incorrect calculations or infinite loops.
9. Explain how an array element is accessed using its index. [3 Marks]
Answer: An array stores elements in contiguous memory locations. Each element is accessed by combining the array name with an index enclosed in brackets, such as A[i]. The index specifies the offset from the base address of the array, allowing the computer to compute the exact memory location and retrieve or update the value directly in O(1) time.
10. What is an infinite loop and how can it be avoided? [3 Marks]
Answer: An infinite loop is a coding error where a loop condition never evaluates to false, causing the program to repeat the block indefinitely. It can be avoided by ensuring that the loop control variable is properly updated inside the loop body and that the terminating condition is achievable.
Section C — 5 Marks Questions
1. Explain the fundamental concept of flowcharts, detailing at least five standard symbols and their specific functions in problem-solving. [5 Marks]
Answer:
Introduction to Flowcharts
A flowchart is a standardized graphical tool used by programmers to map out the logical flow of an algorithm before writing actual code. It provides a visual blueprint of the problem-solving process.
Standard Symbols and Functions
- Terminal (Oval): Indicates the beginning (Start) and end (Stop) points of the flowchart.
- Input/Output (Parallelogram): Used for reading input data from users or displaying output results.
- Process (Rectangle): Represents data manipulation, calculations, or arithmetic assignments.
- Decision (Diamond): Used for branching and checking conditions, directing flow based on true or false outcomes.
- Flow Lines (Arrows): Connect different symbols and show the exact direction of program execution.
Conclusion
Using these standardized symbols ensures that programmers can design, communicate, and debug logical solutions clearly before implementation.
2. Discuss decision-making structures in programming algorithms, focusing on if-then, if-then-else, and nested if-then-else constructs with examples. [5 Marks]
Answer:
Introduction to Decision Making
Decision-making structures allow algorithms to alter their execution path based on specific conditions, moving beyond purely sequential execution.
If-Then Structure
The simplest decision structure executes a block of statements only when the condition is true. If false, the statements are skipped entirely.
If-Then-Else Structure
This structure provides two alternative paths. If the condition is true, block A executes; otherwise, block B executes, ensuring a decision is always resolved.
Nested If-Then-Else Structure
When multiple conditions must be evaluated hierarchically, structures are nested. For example, determining the largest of three numbers requires checking if A > B, and within that branch, checking if A > C.
Example and Importance
Decision structures form the backbone of logical branching in software, allowing programs to respond dynamically to varying inputs and user choices.
3. Explain the mechanics of iterative control structures and looping, specifically focusing on the repeat-while loop and its execution steps. [5 Marks]
Answer:
Introduction to Iteration
Iteration or looping allows algorithms to execute a set of instructions multiple times without duplicating code, making programs efficient and concise.
The Repeat-While Loop Mechanism
The repeat-while structure operates by repeatedly executing a block of code as long as a specified condition evaluates to true.
Steps in a Loop
- Initialization: Setting up the loop control variable and counters.
- Execution: Performing the statements inside the loop body.
- Update: Modifying the loop control variable so it progresses toward termination.
- Condition Check: Evaluating the logical test to decide whether to repeat or exit.
Example
Calculating the sum of the first ten natural numbers requires initializing a sum to zero, a counter to one, and looping while the counter is less than or equal to ten.
4. Describe the concept of arrays in computer programming, explaining how they store data and how algorithms process one-dimensional arrays. [5 Marks]
Answer:
Introduction to Arrays
An array is a linear data structure that stores a fixed-size sequential collection of elements of the same data type under a single identifier.
Memory Allocation and Indexing
Array elements are stored in contiguous memory locations. Each element is accessed via an index, starting from zero up to n - 1, enabling rapid random access.
Processing Arrays with Loops
Because arrays hold multiple elements, algorithms use loops (such as repeat-while) to traverse, search, update, or compute values across the entire array.
Common Operations
- Traversing all elements to print or display values.
- Searching for a specific element.
- Finding the maximum or minimum value in the array.
Conclusion
Arrays are fundamental for managing collections of data efficiently in algorithmic problem solving.
5. Outline the complete problem-solving lifecycle with computers, from understanding a problem to designing algorithms and flowcharts. [5 Marks]
Answer:
Introduction
Problem-solving with computers is a systematic process that transforms a real-world problem into an executable, tested algorithmic solution.
Key Phases of Problem Solving
- Problem Definition: Clearly understanding what needs to be solved, identifying inputs, and determining expected outputs.
- Algorithm Design: Developing a step-by-step logical plan using pseudocode or clear instructions.
- Flowchart Creation: Translating the algorithm into a visual flowchart using standard symbols to map decision paths and loops.
- Coding and Implementation: Writing the solution in a programming language based on the algorithm.
- Testing and Debugging: Running test cases to identify logical or syntax errors and ensuring the output is correct.
Conclusion
Following this structured lifecycle ensures robust, error-free, and well-documented programming solutions.