Answers to Questions 1-10 (Verified from Reference Books)
Q1. Define algorithm. Explain its characteristics.
An algorithm is a finite set of well-ordered, unambiguous steps to solve a problem.
Characteristics of an Algorithm:
1. Finiteness - Must terminate after finite steps
2. Definiteness - Each step is clearly defined
3. Input - Accepts zero or more inputs
4. Output - Produces at least one output
5. Effectiveness - Steps are basic and feasible
Reference: Introduction to Programming by Deepak Gupta, Chapter 2, pp. 15-16
Q2. Write algorithm for average of three numbers.
Algorithm:
1. Start
2. Input a, b, c
3. sum <- a + b + c
4. avg <- sum / 3
5. Print avg
6. Stop
Reference: Deepak Gupta, Chapter 2, Example 2.3, p. 18
Q3. Define flowchart and list symbols.
A flowchart is a diagrammatic representation of an algorithm using standard symbols.
Symbols:
- Oval: Start/End
- Rectangle: Process
- Parallelogram: Input/Output
- Diamond: Decision
- Arrow: Flow line
Reference: Deepak Gupta, Chapter 3, pp. 24-25
Q4. Explain each symbol with example.
Example: Flowchart for computing sum of two numbers uses:
- Oval for Start/End
- Parallelogram for Input/Output
- Rectangle for Process
- Arrows for Flow
Reference: Deepak Gupta, Chapter 3, pp. 26-28
Q5. Define data type. List types with sizes.
Data type defines the kind of data a variable can store.
Common Data Types:
| Type | Size |
|--------|------------|
| int | 2 or 4 bytes |
| float | 4 bytes |
| char | 1 byte |
| double | 8 bytes |
Reference: Deepak Gupta, Chapter 4, p. 35
Q6. Define variable; write declaration; rules.
A variable is a named memory location storing values that can change.
Declaration: int age; float salary;
Rules:
1. Begins with letter/underscore
2. No keywords
3. Case-sensitive
4. Only '_' as symbol
5. Declare before use
Reference: Sachin Kumar & Kadambari Agarwal, Chapter 1, pp. 42-43
Q7. Define constant; distinguish from variable.
A constant is a fixed value in code that cannot change. Variables can be modified; constants cannot.
Reference: Deepak Gupta, Chapter 4, pp. 36-37
Q8. What is compilation? Define compiler and assembler.
Compilation converts source code into object code.
- Compiler: Checks syntax, optimizes and generates code
- Assembler: Converts assembly code to machine code
Reference: Deepak Gupta, Chapter 5, pp. 45-47
Q9. Discuss sequence control and subprogram control.
Sequence control executes statements linearly. Subprogram control involves invoking modules
(functions) with arguments and return values.
Reference: Sachin Kumar & Agarwal, Chapter 2, pp. 60-62
Q10. Explain programming languages and their roles.
A programming language provides structure and translation from human logic to machine-level
execution.
Roles include abstraction, structuring, translation, and hardware interfacing.
Reference: Sachin Kumar & Agarwal, Chapter 1, pp. 10-12