C Tutorial — Learn C Programming
Key takeaway: This free C tutorial teaches you systems programming from scratch — variables, pointers, arrays, functions, structs, and memory management — with practical code examples you can compile and run.
C is a general-purpose, procedural programming language created in 1972. It is used for operating systems, embedded systems, game engines, and performance-critical applications. This tutorial is for beginners, CS students, and developers who want to understand how computers work at a low level.
Last updated: September 2026
Pointers & Functions
Passing pointers to functions enables pass-by-reference semantics. This allows a function to modify the caller’s variables or operate efficiently on arrays.
#include <stdio.h>
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
void modifyArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] *= 2; // Double each element
}
}
int main() {
int x = 10, y = 20;
printf("Before swap: x = %d, y = %d\n", x, y);
swap(&x, &y);
printf("After swap: x = %d, y = %d\n", x, y);
int numbers[] = {1, 2, 3, 4, 5};
printf("\nOriginal array: ");
for (int i = 0; i < 5; i++) {
printf("%d ", numbers[i]);
}
modifyArray(numbers, 5);
printf("\nModified array: ");
for (int i = 0; i < 5; i++) {
printf("%d ", numbers[i]);
}
printf("\n");
return 0;
}Important Notes
- & (address-of) obtains a variable’s address.
- * (dereference) reads/writes the value at an address.
- Initialize pointers before use to avoid undefined behavior.