3. Programming Concepts: Questions and Answers

Select a question to reveal its answer.

Part AMultiple Choice Questions

1Which phase comes first in the programming life cycle?
  • a) Coding
  • b) Debugging
  • c) Problem Identification
  • d) Documentation
Answer

c) Problem Identification

2Which flowchart symbol represents a decision?
  • a) Rectangle
  • b) Oval
  • c) Parallelogram
  • d) Diamond
Answer

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
Answer

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
Answer

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
Answer

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
Answer

c) Run-time error

7Typing prnt instead of print causes:
  • a) Logical error
  • b) Syntax error
  • c) Run-time error
  • d) No error
Answer

b) Syntax error

8Comments written inside the source code are called:
  • a) User manual
  • b) Technical guide
  • c) Internal documentation
  • d) External documentation
Answer

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
Answer

c) Iteration

10Which language uses a compiler?
  • a) Python
  • b) JavaScript
  • c) C++
  • d) None of these
Answer

c) C++

Part BShort Answer Questions

1Define an algorithm.
Answer

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?
Answer
  1. What raw data or facts do we have (input)?
  2. What final result do we want (output)?
  3. How do we transform the data into the result (process)?
3What are the general rules for writing algorithms?
Answer
  • 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?
Answer

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.
Answer
SymbolNameUse
Rounded rectangle (oval)TerminatorStart / End
RectangleProcessCalculation or action
DiamondDecisionYes/No or True/False branching
ParallelogramInput/OutputReading input or displaying output
ArrowFlow lineDirection of flow
CircleConnectorLinking different sections of a flowchart
6Differentiate between a compiler and an interpreter.
Answer
CompilerInterpreter
Translates the whole program at onceTranslates and executes line by line
Generates a separate object code fileDoes not generate an object code file
Lists all errors at the endStops at the first error found
Used by C and C++Used by Python and JavaScript
7What is debugging? Name the three types of errors.
Answer

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.
Answer

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.
Answer

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?
Answer
  • 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.
Answer
  1. Problem Identification: Define the gap between the current state and the desired state by identifying the input, output and process.
  2. Algorithms and Flowcharts: Design a logical plan in plain English (algorithm) and as a diagram (flowchart).
  3. Coding: Translate the algorithm into source code using a high-level language such as Python.
  4. Translation: A compiler or interpreter converts the source code into machine-readable object code.
  5. Debugging: Find and fix syntax, logical and run-time errors.
  6. Execution and Testing: Run the program with normal, boundary and invalid data to check that it is accurate and reliable.
  7. Documentation: Prepare internal documentation (comments) and external documentation (user and technical manuals).
2Explain the three types of control flow with real-life examples.
Answer
  • 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.
Answer
  • 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.
Answer
Procedure-Oriented (POP)Object-Oriented (OOP)
Treats a program as a step-by-step recipe of proceduresModels software on real-world entities as objects
Functions run one after another from top to bottomObjects bundle data (attributes) and methods (actions)
Data is often shared across the whole programData can be hidden inside objects
Easier for beginners, but risky for complex projectsHarder to learn, but better for complex systems
Examples: C, PascalExamples: Python, Java, C++

Part DApplication Questions

1Write an algorithm to find the simple interest.
Answer
Step 1: Start
Step 2: Input P, R, T
Step 3: SI = (P x R x T) / 100
Step 4: Print SI
Step 5: Stop
2Write an algorithm to find the area and perimeter of a rectangle.
Answer
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: Stop
3Write an algorithm to find the highest of two numbers.
Answer
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: Stop
4Write a Python program to calculate the total and percentage of marks in six subjects.
Answer
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?
Answer

Total = 75 x 6 = 450. Percentage = (450 / 600) x 100 = 75%.

6Identify the error type in each case.
Answer
  • 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?
Answer

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.