Introduction to C & Setup
Duration: 45 min
C is a powerful, low-level programming language created by Dennis Ritchie in 1972. It remains one of the most influential languages in computer science, forming the foundation for Unix, Linux, and countless modern systems. In this module, you'll learn C's history, set up your development environment, and write your first program.
History & Why C Matters
C revolutionized programming by providing a balance between high-level abstraction and low-level hardware control. It's used in operating systems, embedded systems, databases, and performance-critical applications. Understanding C teaches you how computers actually work.
Setting Up Your Environment
On macOS
// Install Xcode Command Line Tools
// Open Terminal and run:
// xcode-select --install
// Verify gcc is installed
gcc --versionOn Linux (Ubuntu/Debian)
// Install gcc and build tools
// sudo apt-get update
// sudo apt-get install build-essential
// Verify installation
gcc --versionOn Windows
// Download MinGW from mingw-w64.org
// Add to PATH
// Verify: gcc --versionYour First Program: Hello World
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}Save this as hello.c and compile:
// gcc hello.c -o hello
// ./hello
// Output: Hello, World!Understanding the Compilation Process
// Source code (hello.c) → Preprocessor → Compiler → Assembler → Linker → Executable
// Step 1: Preprocessing (handles #include, #define)
// gcc -E hello.c
// Step 2: Compilation (converts to assembly)
// gcc -S hello.c
// Step 3: Assembly (converts to object code)
// gcc -c hello.c
// Step 4: Linking (creates executable)
// gcc hello.o -o helloCommon GCC Flags
// gcc -Wall hello.c -o hello // Enable all warnings
// gcc -g hello.c -o hello // Include debug symbols
// gcc -O2 hello.c -o hello // Optimize for speed
// gcc -std=c99 hello.c -o hello // Use C99 standardProgram Structure
#include <stdio.h> // Include standard I/O library
int main() { // Entry point of program
// Your code here
return 0; // Return 0 to indicate success
}Quiz 1: C History
❓ Who created the C programming language?
Quiz 2: Compilation
❓ What is the correct order of the compilation process?
Quiz 3: Hello World
❓ What does `#include
Quiz 4: GCC Flags
❓ Which flag enables all compiler warnings?
Quiz 5: Return Value
❓ What does `return 0;` in main() indicate?