Phase 1 · C FoundationsModule 1~38 min read

Introduction to Programming & C

Discover what C is, how source code becomes a native program, set up a compiler, and build your first program from the terminal.

What you'll learn

C puts you close to the machine without forcing you to write raw processor instructions. In this first lesson, you'll build a precise mental model of how C programs are created, install the essential tools, and compile your first native executable.

By the end, you'll be able to:

  • Explain what makes C different from interpreted and virtual-machine languages
  • Describe preprocessing, compilation, linking, and execution
  • Compile a warning-clean C17 program with GCC or Clang
  • Read the essential parts of a small C source file

How to use this course

Type every example yourself, compile with the warning flags shown, and experiment with one small change at a time. In C, compiler diagnostics are part of the lesson—not background noise.

What is C?

C is a general-purpose programming language created by Dennis Ritchie at Bell Labs in the early 1970s. It was designed to build Unix, so it combines readable structured code with direct access to memory and hardware-friendly data.

C is small by modern language standards. It does not include classes, garbage collection, exceptions, or a huge built-in library. That simplicity gives it an enormous reach: compilers can target tiny microcontrollers, desktop computers, servers, and supercomputers.

Key idea

C gives you control, not automatic safety. The language trusts your array indexes, pointer arithmetic, formats, and object lifetimes. Our job is to build habits that make that control dependable.

Where C is used

You may not see C on a screen, but you use software written in C constantly. It thrives wherever predictable performance, a small runtime, portability, or hardware access matters.

C beneath the software stack

Operating systems

Linux · Windows · kernels

Embedded systems

Cars · sensors · appliances

Language runtimes

CPython · compilers · VMs

Infrastructure

Databases · servers · networks

Games & graphics

Engines · drivers · libraries

Everyday libraries

Git · SQLite · curl

C is often the layer that higher-level software relies on.

Learning C also improves your understanding of other languages. Arrays, references, object lifetimes, stack frames, binary data, and operating-system APIs become less mysterious once you have worked with their foundations directly.

How C becomes a program

A C source file is text for humans. Your processor needs machine instructions. A toolchain transforms one into the other:

From main.c to a native executable
main.cSourceYour C code
→
preprocessorExpandHeaders & macros
→
compilerTranslateC to object code
→
linkerCombineCode & libraries
→
programExecuteNative machine code
A compiler driver such as gcc coordinates every stage.
  1. The preprocessor handles directives such as #include.
  2. The compiler checks and translates C into lower-level instructions.
  3. The assembler creates an object file containing machine code.
  4. The linker combines your object code with required libraries.
  5. The operating system loads the resulting executable.

Note

People often call the whole toolchain “the compiler.” That shorthand is fine, but knowing the stages will later make missing headers, duplicate symbols, and linker errors much easier to diagnose.

Compiler & editor setup

Install either GCC or Clang. On Windows, a convenient route is MSYS2, WSL, or a native LLVM installation. On macOS, install the Xcode Command Line Tools. Linux distributions provide GCC or Clang through their package manager.

Open a fresh terminal and verify that at least one compiler is available:

Terminal
gcc --version
clang --version
Your exact compiler name and version will differ.

Use an editor that can show diagnostics and navigate code, but keep the terminal workflow. VS Code with a C extension, CLion, Visual Studio, and many lighter editors are all valid.

Your first program: Hello, World!

Create a file named main.c. C source files conventionally use the.c extension:

main.c
#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");
    return 0;
}
The Run button displays the expected output; compile locally to execute the program for real.

Compile it with strict warnings enabled, then run the executable:

Terminal
gcc -std=c17 -Wall -Wextra -Wpedantic main.c -o hello
./hello

Keep the warnings

-std=c17 selects the language standard. -Wall -Wextra -Wpedanticasks the compiler to explain suspicious code. Use these flags throughout the course.

Anatomy of a C program

  • #include <stdio.h> makes declarations for standard input/output available.
  • int main(void) defines the program's starting function.
  • Braces create the function body—a block of statements.
  • printf writes formatted output; \n starts a new line.
  • return 0; tells the environment that the program succeeded.
  • Most C statements end with a semicolon.

C is case-sensitive

main, Main, and MAIN are different identifiers. Standard-library names such as printf must use their exact spelling and case.

The development workflow

A reliable C workflow is deliberately repetitive:

  1. Edit one small piece of source code.
  2. Compile with strict warnings.
  3. Fix the first diagnostic, then compile again.
  4. Run the program with normal, boundary, and invalid inputs.
  5. Save a working checkpoint in version control.

Compiler diagnostics normally include a file, line, column, severity, and message. Start at the first error: later errors are often consequences of one missing quote, brace, or semicolon.

Comments

C supports line comments and block comments. Comments should record intent, constraints, or a surprising decision—not translate obvious code into English.

comments.c
#include <stdio.h>

int main(void) {
    // A line comment ends at the newline.
    printf("C rewards precision.\n");

    /*
     * A block comment can span
     * several lines.
     */
    return 0;
}

Tip

Prefer clear names and small functions first. Add a comment when a future reader needs to know why the code is written that way.

Recap & quick check

Key takeaways

  • C is a small, portable systems language that compiles to native code.
  • The build pipeline preprocesses, compiles, assembles, and links source files.
  • main is the program entry point, and returning zero reports success.
  • Strict compiler warnings are an everyday correctness tool.
  • The core learning loop is edit, compile, read diagnostics, run, and test.

Quick check

1. Which stage combines object code with required libraries?

2. What does returning 0 from main conventionally mean?

3. Why compile with -Wall -Wextra -Wpedantic?

4. What does #include <stdio.h> provide for this lesson?

Your toolchain is ready. Next up: Module 2 — Variables, Data Types & Operators, where programs begin storing and transforming real data.