Chapter 1: Introduction to C Programming
1. What exactly is C?
C is a general-purpose, procedural programming language. It was created between 1972–1973 by Dennis Ritchie at Bell Labs (USA) while he was working on developing the UNIX operating system.
Think of C as the “mother” of many modern programming languages:
- C++ was built on top of C
- Java, C#, Go, Rust, Python (its interpreter is written in C), JavaScript engines, etc., all have heavy influence from C
2. Why was C created? (The real story)
In the early 1970s, most operating systems were written in assembly language — very low-level, machine-specific, and extremely hard to write big programs with.
Dennis Ritchie and Ken Thompson wanted to:
- Write the UNIX operating system in a high-level language (easier to read/write/maintain)
- But they still needed complete control over memory and hardware (like assembly)
So they created C — a language that gives you almost the same power as assembly, but with much nicer syntax and portability.
Result? UNIX was rewritten in C in 1973 — and that changed the history of computing forever.
3. Main Features of C (Why people still love it in 2026)
| Feature | What it means for you |
|---|---|
| Structured programming | You can write clean, organized code using functions, loops, if-else, etc. |
| Low-level access | You can directly work with memory addresses (pointers) and hardware |
| Very fast | Almost as fast as assembly — used in games, OS, drivers, embedded systems |
| Portable | Write once, compile anywhere (with minor changes) |
| Small & simple | Only 32 keywords — very small language to learn |
| Standardized | C89, C99, C11, C17, C23 — there are official standards |
| Huge ecosystem | Millions of libraries, tools, and open-source projects |
4. Where is C used today? (Real-world examples – 2026)
| Domain | Famous Examples using C / C-based code |
|---|---|
| Operating Systems | Linux kernel, Windows kernel parts, macOS kernel (XNU), Android kernel |
| Embedded Systems | Microcontrollers (Arduino, STM32, ESP32), car ECUs, washing machines, IoT |
| Game Engines | Unreal Engine, Unity (core parts), Godot (parts) |
| Databases | MySQL, PostgreSQL, SQLite |
| Compilers & Interpreters | GCC (GNU Compiler Collection), Clang, Python interpreter, Ruby, PHP |
| Browsers | Chrome (V8 engine), Firefox (SpiderMonkey) |
| Graphics & Multimedia | OpenGL, Vulkan, FFmpeg, GStreamer |
| High-performance apps | Redis, Nginx, Apache web server |
| Competitive Programming | Almost every top coder uses C/C++ for speed |
Fun fact: Even today, 90%+ of the world’s supercomputers run Linux — which is written mostly in C.
5. Different Versions of C (Quick Timeline)
| Year | Standard | Nickname | Important New Features |
|---|---|---|---|
| 1972 | — | K&R C | Original version (book by Kernighan & Ritchie) |
| 1989 | ANSI C | C89 / C90 | First official standard |
| 1999 | C99 | — | Variable-length arrays, inline functions, bool type |
| 2011 | C11 | — | Multithreading support, anonymous structs/unions |
| 2018 | C17 | — | Mostly bug fixes |
| 2024 | C23 | — | nullptr, constexpr, typeof, better enums, attributes |
Most common today (2026): C11 and C17 are widely supported. Many people still write C99-style code because it’s very stable.
6. How a C Program Works (Big Picture)
- You write code in a .c file → hello.c
- Preprocessor runs first (#include, #define…)
- Compiler turns C code into assembly code
- Assembler turns assembly into machine code (object file .o)
- Linker combines your object file + libraries → final executable (hello.exe or ./hello)
- You run the executable
7. Your Very First Program – Hello World (with detailed explanation)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// This is a single-line comment /* This is a multi-line comment */ // 1. We need this line to use printf() #include <stdio.h> // 2. Every C program must have exactly one main() function int main() // int = it will return an integer { // { = start of main function body // 3. printf() is a function that prints text to screen // \n means "go to new line" printf("Hello, World!\n"); // 4. return 0 means "program finished successfully" // (0 = success, any other number usually means error) return 0; } // } = end of main function |
How to save, compile, and run (on Windows, Linux, macOS):
Method 1 – Using Terminal / Command Prompt
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# 1. Save the file as hello.c # 2. Compile it gcc hello.c -o hello # 3. Run it # Linux/macOS: ./hello # Windows: hello.exe |
Method 2 – Using an IDE (recommended for beginners)
- VS Code + Code Runner extension
- Code::Blocks
- Dev-C++
- CLion (paid, but student license free)
8. Common First Mistakes Beginners Make
- Forgetting semicolon ; at the end of statements
- Forgetting #include <stdio.h>
- Writing main() instead of int main()
- Forgetting return 0;
- Writing Print instead of printf (case-sensitive!)
9. One More Simple Example – Printing Your Name
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#include <stdio.h> int main() { printf("My name is Webliance!\n"); printf("I am learning C in 2026!\n"); printf("Today is January 20, 2026.\n"); return 0; } |
10. Homework for Today
- Install a compiler / IDE (I recommend VS Code + MinGW on Windows or gcc on Linux/macOS)
- Write the Hello World program
- Change the message to something personal (your name, city, dream, etc.)
- Compile and run it
- Try to intentionally make 2–3 mistakes (forget ; , wrong spelling, etc.) and see what error messages you get — this is the best way to learn!
Tomorrow we will go to Chapter 2: Variables, Data Types & Constants — the real foundation of programming!
Any questions about this chapter? Want me to explain any part again? Or shall we move to Chapter 2 right now? 😊
