Answers to Questions 21-37 (Verified from Reference Books)
Q21. Differentiate between pointers and arrays
Pointers:
- Store address of variable
- Can be reassigned
- Allow pointer arithmetic
Arrays:
- Store data elements
- Fixed size
- Cannot be reassigned
Reference: Deepak Gupta pp. 8283
Q22. What are the features of pointers?
- Efficient memory access
- Dynamic memory allocation
- Passing by reference
- Data structure implementation
Reference: Deepak Gupta pp. 8183
Q23. Define function. Explain the types of functions with an example.
Function: Reusable block of code
Types:
1. No args, no return
2. Args, no return
3. No args, return
4. Args, return
Example:
int add(int a, int b) { return a + b; }
Reference: Deepak Gupta pp. 7275
Q24. What is Compilation? Explain in brief.
Compilation is converting source code into machine code via compiler.
Steps:
Lexical Syntax Semantic Optimization Code Generation
Reference: Deepak Gupta pp. 4547
Q25. Write notes on: i) Compiler ii) Interpreter iii) Assembler
Compiler: Converts full code to object code
Interpreter: Line-by-line execution
Assembler: Converts assembly to machine code
Reference: Deepak Gupta pp. 4749
Q26. Write difference between algorithm and flowchart
Algorithm: Textual steps
Flowchart: Diagrammatic flow using symbols
Reference: Deepak Gupta pp. 1528
Q27. Define keyword, constant, and variable
Keyword: Reserved word (int, if)
Constant: Fixed value (e.g. 10)
Variable: Storage location with changeable value
Reference: Deepak Gupta pp. 3537
Q28. Write an algorithm and flowchart to find the sum of numbers from 1 to n
Algorithm:
1. Start
2. Input n
3. sum=0
4. for i=1 to n sum=sum+i
5. Output sum
6. Stop
Reference: Deepak Gupta pp. 2022
Q29. Define algorithm. Write algorithm for finding factorial of a number
Algorithm:
1. Start
2. Input n
3. fact=1
4. for i=1 to n fact=fact*i
5. Output fact
6. Stop
Reference: Deepak Gupta pp. 2022
Q30. Write an algorithm and flowchart to generate Fibonacci series up to 'n'
Algorithm:
1. Start
2. Input n
3. a=0, b=1
4. Print a, b
5. Repeat c=a+b, print c, a=b, b=c
6. Stop
Reference: Deepak Gupta pp. 2223
Q31. Draw the flowchart to find the greatest of three numbers
Compare a, b, c using if-else logic in decision symbols of flowchart.
Reference: Deepak Gupta pp. 2728
Q32. Write an algorithm and flowchart to find whether a number is prime or not
Algorithm:
1. Start
2. Input n
3. flag=0
4. for i=2 to n-1: if n%i==0 then flag=1
5. if flag==0 Prime
else Not Prime
6. Stop
Reference: Deepak Gupta pp. 2730
Q33. What is Multi-dimensional Array?
Array with more than one index, e.g., int arr[2][3][4];
Reference: Deepak Gupta pp. 6768
Q34. What is Pointer to Pointer?
Pointer holding address of another pointer
Example:
int a=10;
int *p=&a;
int **pp=&p;
Reference: Deepak Gupta pp. 8485
Q35. What is Program?
Set of instructions to perform a task
Reference: Sachin Kumar pp. 23
Q36. What is Structured, Procedural, and Object-Oriented Programming Language?
Structured: Uses blocks, loops (C)
Procedural: Based on procedures (Pascal, C)
OOP: Uses objects & classes (Java, C++)
Reference: Sachin Kumar pp. 8082
Q37. What is Loop? Why to have loops? Explain
Loop: Repeats block of code while condition is true
Benefits:
- Avoid repetition
- Automate tasks
- Clean code
Reference: Deepak Gupta pp. 5156