Part AMultiple Choice Questions
1Which phase comes first in the programming life cycle?
- a) Coding
- b) Debugging
- c) Problem Identification
- d) Documentation
c) Problem Identification
2Which flowchart symbol represents a decision?
- a) Rectangle
- b) Oval
- c) Parallelogram
- d) Diamond
d) Diamond
3The word "algorithm" comes from the name of:
- a) Charles Babbage
- b) Alan Turing
- c) Muhammad Ibn Musa Al-Khwarizmi
- d) Blaise Pascal
c) Muhammad Ibn Musa Al-Khwarizmi
A Persian mathematician who lived around 820 AD.
4The native language of a computer is:
- a) English
- b) Binary code
- c) Python
- d) Pseudocode
b) Binary code
Also called machine language.
5Which translator reads and executes the program one line at a time?
- a) Compiler
- b) Interpreter
- c) Assembler
- d) Debugger
b) Interpreter
6"Division by zero" is an example of which error?
- a) Syntax error
- b) Logical error
- c) Run-time error
- d) Compilation error
c) Run-time error
7Typing prnt instead of print causes:
- a) Logical error
- b) Syntax error
- c) Run-time error
- d) No error
b) Syntax error
8Comments written inside the source code are called:
- a) User manual
- b) Technical guide
- c) Internal documentation
- d) External documentation
c) Internal documentation
9Which flow of control repeats a set of instructions while a condition is true?
- a) Sequential
- b) Selection
- c) Iteration
- d) Branching
c) Iteration
10Which language uses a compiler?
- a) Python
- b) JavaScript
- c) C++
- d) None of these
c) C++
Part BShort Answer Questions
1Define an algorithm.
An algorithm is a step-by-step procedure written in plain language to solve a problem. It works like a recipe and is written before the program code.
2What are the three key components to look for in problem identification?
- What raw data or facts do we have (input)?
- What final result do we want (output)?
- How do we transform the data into the result (process)?
3What are the general rules for writing algorithms?
- It must have a clear Start and Stop.
- It must be unambiguous (say exactly what to do).
- Each step should be simple, with one action per step.
- It must end and cannot go on forever.
4What is a flowchart?
A flowchart is a pictorial representation of an algorithm. It uses standard geometric shapes connected by arrows to show the flow of control.
5Name the standard flowchart symbols and their uses.
| Symbol | Name | Use |
|---|---|---|
| Rounded rectangle (oval) | Terminator | Start / End |
| Rectangle | Process | Calculation or action |
| Diamond | Decision | Yes/No or True/False branching |
| Parallelogram | Input/Output | Reading input or displaying output |
| Arrow | Flow line | Direction of flow |
| Circle | Connector | Linking different sections of a flowchart |
6Differentiate between a compiler and an interpreter.
| Compiler | Interpreter |
|---|---|
| Translates the whole program at once | Translates and executes line by line |
| Generates a separate object code file | Does not generate an object code file |
| Lists all errors at the end | Stops at the first error found |
| Used by C and C++ | Used by Python and JavaScript |
7What is debugging? Name the three types of errors.
Debugging is the process of identifying, locating and correcting bugs (errors) in a program. The three types are syntax errors, logical errors and run-time errors.
8Explain a logical error with an example.
A logical error occurs when the program runs without crashing but gives a wrong result because of faulty logic. To find the average of 10 and 20, the correct formula is (10+20)/2 = 15. If written as 10+20/2, the computer divides first (20/2 = 10) and then adds 10, giving 20. This is wrong, but the translator cannot detect it.
9Differentiate between execution and testing.
Execution is simply running a program to process data. Testing is the deliberate process of checking the program for errors by verifying its results under different conditions. Execution proves the code works, but testing proves it is correct.
10Why is documentation important?
- It acts as a memory aid for the original programmer.
- It enables teamwork, since others can understand the code without constant explanation.
- It makes maintenance easier, so future developers can fix or upgrade the system.
Part CLong Answer Questions
1Explain the different phases of programming in detail.
- Problem Identification: Define the gap between the current state and the desired state by identifying the input, output and process.
- Algorithms and Flowcharts: Design a logical plan in plain English (algorithm) and as a diagram (flowchart).
- Coding: Translate the algorithm into source code using a high-level language such as Python.
- Translation: A compiler or interpreter converts the source code into machine-readable object code.
- Debugging: Find and fix syntax, logical and run-time errors.
- Execution and Testing: Run the program with normal, boundary and invalid data to check that it is accurate and reliable.
- Documentation: Prepare internal documentation (comments) and external documentation (user and technical manuals).
2Explain the three types of control flow with real-life examples.
- Sequential: Instructions run one after another from top to bottom, like baking a cake (mix, pour, bake).
- Branching or Selection: The program chooses a path based on a condition using If...Then...Else logic, like stopping at a red light and moving at a green one.
- Iteration or Looping: A set of instructions repeats while a condition is true, like climbing stairs by repeating "step up" until you reach the top.
3Explain the three types of programming errors.
- Syntax errors are violations of the language's grammar rules, such as misspelled keywords or missing punctuation. They are detected during translation and stop the program from starting.
- Logical errors are mistakes in formulas or logic. The program runs but gives the wrong answer, and they are found only by testing.
- Run-time errors occur while the program is running, often because of unexpected events such as invalid input or division by zero. They cause the program to stop suddenly.
4Compare procedure-oriented and object-oriented programming.
| Procedure-Oriented (POP) | Object-Oriented (OOP) |
|---|---|
| Treats a program as a step-by-step recipe of procedures | Models software on real-world entities as objects |
| Functions run one after another from top to bottom | Objects bundle data (attributes) and methods (actions) |
| Data is often shared across the whole program | Data can be hidden inside objects |
| Easier for beginners, but risky for complex projects | Harder to learn, but better for complex systems |
| Examples: C, Pascal | Examples: Python, Java, C++ |
Part DApplication Questions
1Write an algorithm to find the simple interest.
Step 1: Start
Step 2: Input P, R, T
Step 3: SI = (P x R x T) / 100
Step 4: Print SI
Step 5: Stop2Write an algorithm to find the area and perimeter of a rectangle.
Step 1: Start
Step 2: Input Length, Breadth
Step 3: Perimeter = 2 x (Length + Breadth)
Step 4: Area = Length x Breadth
Step 5: Print Perimeter, Area
Step 6: Stop3Write an algorithm to find the highest of two numbers.
Step 1: Start
Step 2: Input M1, M2
Step 3: If M1 > M2, go to Step 4, else go to Step 5
Step 4: Print "M1 is higher". Go to Step 6
Step 5: Print "M2 is higher"
Step 6: Stop4Write a Python program to calculate the total and percentage of marks in six subjects.
m1 = int(input("Enter Mark 1: "))
m2 = int(input("Enter Mark 2: "))
m3 = int(input("Enter Mark 3: "))
m4 = int(input("Enter Mark 4: "))
m5 = int(input("Enter Mark 5: "))
m6 = int(input("Enter Mark 6: "))
total = m1 + m2 + m3 + m4 + m5 + m6
max_marks = 600
percentage = (total / max_marks) * 100
print("Total Marks =", total)
print("Percentage =", percentage)5A student scores 75 in each of six subjects. What are the total and percentage?
Total = 75 x 6 = 450. Percentage = (450 / 600) x 100 = 75%.
6Identify the error type in each case.
- Writing prnt("Hello"): Syntax error
- Using total = m1 + m2 + m3 + m4 + m5 + m6 / 6 to find the average: Logical error
- A teacher types the word "Fifty" for a mark, and the program crashes: Run-time error
7Why is a flowchart sometimes less practical than an algorithm?
Flowcharts are time-consuming to draw neatly. They are also difficult to modify, because adding a new decision branch often means redrawing the whole diagram, while text can be edited easily.