C Programming Notes
1. Introduction to C
C is a general-purpose, procedural programming language developed in the early 1970s by Dennis
Ritchie. It provides low-level access to memory and is widely used for system/software
development.
2. Basic Structure of a C Program
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
3. Data Types in C
Primary data types: int, float, char, double
Derived data types: array, pointer, structure, union
Qualifiers: signed, unsigned, long, short
4. Control Structures
Conditional: if, if-else, switch
Loops: for, while, do-while
Jump: break, continue, goto, return
5. Functions
A function is a block of code that performs a specific task. Syntax:
return_type function_name(parameters) {
// body
}
6. Pointers
A pointer is a variable that stores the memory address of another variable. Use * for value at
address, & for address of a variable.
7. Arrays and Strings
Array is a collection of elements of the same type. Strings are arrays of characters ending with a null
character '\0'.
8. Structures
Structures are user-defined data types that group related variables of different types. Syntax:
struct StructName {
int a;
char b;
};
9. File Handling
C provides functions like fopen, fclose, fprintf, fscanf for file operations. Modes include "r", "w", "a",
"r+", etc.