C Language Handwritten Notes - Complete
Part 1: Basics of C
Introduction to C
- C is a general-purpose, structured programming language.
- Developed by Dennis Ritchie at Bell Labs in 1972.
- Middle-level language, used for OS & embedded systems.
Structure of a C Program
#include
int main() {
printf("Hello, World!");
return 0;
}
Compilation Process
- Write code → Compile → Link → Execute
- Compiler converts to machine code.
Tokens in C
- Keywords, Identifiers, Constants, Variables, Data Types, Operators.
Input & Output
- printf() for output, scanf() for input.
Part 2: Control Statements
Decision Making
if (condition) { ... } else { ... }
switch (choice) { case 1: ...; break; default: ...; }
Loops
for (init; condition; update) { ... }
while (condition) { ... }
do { ... } while (condition);
Jumping Statements
- break, continue, goto
Part 3: Functions
Functions allow modular programming.
Syntax: returnType functionName(parameters) { ... }
Call by Value vs Call by Reference
Recursion: function calling itself.
Part 4: Arrays & Strings
Arrays: int arr[5] = {1,2,3,4,5};
2D Arrays: int mat[2][3];
Strings: char name[20] = "Hello";
String functions: strlen, strcpy, strcat, strcmp
Part 5: Pointers
Pointer: variable storing address of another variable.
int x=10; int *p=&x;
Pointer arithmetic: p++, p--
Pointers with arrays, functions, strings
Part 6: Structures, Unions & Storage Classes
Structure: group of different data types.
struct student { int id; char name[20]; };
Union: shares memory among members.
Storage classes: auto, extern, static, register
Part 7: Memory Management
Dynamic memory allocation:
malloc(size), calloc(n,size), realloc(ptr,size), free(ptr)
Part 8: File Handling & Preprocessor
File Handling
fopen, fclose, fprintf, fscanf, fgetc, fputc
File modes: r, w, a, rb, wb
Preprocessor
#include, #define, Macros
Part 9: Advanced Topics
Command-line arguments
enum (enumerations)
typedef (alias names)
Bitwise operators: &, |, ^, <<, >>