Computer Programming and Data Structures - Complete Notes
Module 1: C Language Fundamentals
1. Introduction to C Language
- C is a middle-level, structured, and portable language developed by Dennis Ritchie (1972).
- Combines features of both low and high-level languages.
2. Constants, Variables and Data Types
- Constants: fixed values; Variables: changeable names.
- Data types: int, float, char, double; Qualifiers: short, long, unsigned.
3. Operators
- Arithmetic, Relational, Logical, Assignment, Conditional, Bitwise.
4. Expressions
- Expressions follow precedence and associativity rules.
5. Input and Output
- scanf(), printf(), getchar(), putchar(); uses stdio.h header.
Module 2: Decision Making, Looping and Functions
6. Decision Making
- if, if...else, nested if, else-if ladder, switch-case.
7. Looping
- while, do...while, for; break and continue.
8. User Defined Functions
- Function syntax: return_type name(arguments);
- Types: No arg/no return, arg with return, etc.
9. Library Functions
- Standard functions from math.h, string.h, stdio.h etc.
10. Scope and Visibility
- Local and Global variables; Storage classes: auto, static, extern, register.
Module 3: Arrays, Structures and Pointers
11. Arrays
- One-dimensional, two-dimensional, and string arrays.
12. Structure and Union
- Structure: heterogeneous data grouping; Union: shared memory.
13. Pointers
- Store addresses; operators: &, *; pointer to pointer; pointers and arrays/functions.
Module 4: Data Structures
14. Linked List
- Singly, Doubly, Circular linked lists; insertion, deletion, traversal.
15. Stack
- LIFO; Push/Pop; Implementation using arrays and linked lists.
16. Queue
- FIFO; Linear and Circular queues; Enqueue/Dequeue operations.
Practice Questions & Answers
1. Who developed C language? - Dennis Ritchie in 1972
2. Difference between = and ==? - Assignment vs Comparison
3. printf for 2 decimals? - printf("%.2f", value);
4. Output of 5/2? - 2
5. What is a symbolic constant? - #define PI 3.14
6. Even check code? - if(num%2==0)
7. while vs do...while? - do runs at least once
8. Square function? - int sq(int x) { return x*x; }
9. Header file example? - math.h with sqrt()
10. Scope of local variable? - Within the function
11. Declare array of 5 ints - int arr[5];
12. Structure vs Union? - Structure = separate memory; Union = shared
13. Declare pointer? - int *p = &a;
14. Access structure with pointer? - ptr->member
15. Output of *p? - Value at pointed location
16. Linked list node? - struct Node {int data; Node *next;}
17. Stack vs Queue? - LIFO vs FIFO
18. Stack operations? - push(), pop()
19. Circular Queue? - rear = (rear+1)%size
20. Why pointers in DS? - Dynamic linking of data