C Programming Complete Notes - Part 1
1. Input/Output
printf() prints output. scanf() reads input. Common format specifiers: %d int, %f float, %c char, %s
string. Escape sequences: \n, \t. printf returns chars printed; scanf returns successful inputs.
2. Variables/Data Types
Variables store data. int, char, float, double. Declare: int a=5;. Scope: local/global. Storage classes:
auto, static, extern, register.
3. Operators
Arithmetic + - * / %, relational == != > < >= <=, logical && || !, bitwise & | ^ ~ << >>, assignment =
+=, increment ++, conditional ?:, sizeof.
4. Control Statements
if, if-else, switch, for, while, do-while, break, continue, goto.
5. Memory
Program layout: Code, Data/BSS, Heap(dynamic), Stack(function calls). Stack is automatic; Heap
is manually managed.
6. Pointers
Pointer stores address. int *p=&a;. NULL pointer points nowhere. Void pointer generic. Wild pointer
uninitialized. Dangling pointer points to freed memory.
7. Dynamic Memory
malloc allocates uninitialized memory, calloc initializes to zero, realloc resizes, free releases
memory. Forgetting free causes memory leaks.
8. Functions & Recursion
Call by value copies data. Call by reference uses addresses. Recursion types: direct, indirect, head,
tail, tree, nested.
9. Arrays & Advanced
Prefix sum, sliding window, two pointers, bit manipulation, rotations, subarrays, pick/no-pick
recursion, bounded/unbounded recursion.