1. Introduction to C
C is a powerful, low-level programming language that gives you direct control over system resources and memory. It was developed by Dennis Ritchie at Bell Labs between 1969 and 1973 as a system programming language for the Unix operating system.
Today, C is still widely used in operating systems, embedded systems, device drivers, and performance-critical applications. Learning C teaches you how computers really work under the hood and forms the foundation for learning C++, Java, Python, and many other languages.
This course will take you from absolute beginner to confident C developer, covering every concept with practical, runnable code examples.
What Can C Do?
C is a systems programming language that powers critical infrastructure across every domain in technology:
- Operating Systems — Windows, Linux, macOS kernels are written in C
- Embedded Systems — Microcontrollers, medical devices, automotive software
- Device Drivers — Hardware communication and control
- Database Systems — MySQL, PostgreSQL are built with C
- Programming Languages — Python, Java, and many other languages are implemented in C
Your First C Program
The tradition in programming is to start by printing Hello, World! to the screen. In C, this requires including the stdio.h header and writing a main function.
#include <stdio.h> int main() { printf("Hello, World! "); return 0; }
The #include directive tells the compiler to include the stdio.h header, which provides input/output functions. The printf() function sends output to the console, and \n adds a new line. The main() function is where every C program starts executing, and return 0; indicates successful completion.
C Syntax vs Other Languages
C has a minimalistic syntax that is the foundation for many modern languages. It uses curly braces to define code blocks and semicolons to terminate statements.
#include <stdio.h> int main() { // This is a C comment — the compiler ignores this line printf("C uses semicolons and curly braces. "); printf("Every statement ends with a semicolon. "); return 0; }
The // symbol marks a single-line comment. Comments are notes for humans reading the code — the compiler completely ignores them. C also supports multi-line comments with /* */.
C Standards and Versions
C has evolved through several standards over the decades:
- K&R C — The original C (1978)
- ANSI C (C89/C90) — The first standard (1989)
- C99 — Added new features like inline functions and variable-length arrays
- C11 — Added multi-threading support
- C17 — The latest standard with bug fixes
- C23 — The upcoming standard
For this course, we will use C99 and C11 features. Most compilers support these standards by default.
Compiling and Running C Code
C is a compiled language. You write source code in a .c file, compile it with a compiler like gcc or clang, and then run the resulting executable file.
#include <stdio.h> int main() { printf("Compile with: gcc -o hello hello.c "); printf("Run with: ./hello "); return 0; }
Understanding the compile-run cycle is fundamental to working with C. The compiler translates your human-readable code into machine code that your computer's processor can execute directly.
Knowledge Check
Ready to test your understanding of 1. Introduction to C?