---
title: "2. Introduction to C Programming"
description: 'Learn the core features of C, write your first program, and understand the compilation pipeline.'
---
C is a small, fast, portable systems programming language that powers operating systems, databases, and embedded devices.

## Features of C

- Small core language with powerful composition
- Close to hardware, predictable performance
- Portable across architectures

## C standards

- ANSI C (C89/C90), C99, C11 (and later like C17)
- We'll use `-std=c11` for examples

## Your first C program

To build via make:

- make hello_world

To run:

- ./bin/hello_world

## The compilation pipeline

1. Preprocessor expands macros and includes headers
2. Compiler turns C into assembly/object code
3. Assembler produces `.o` files
4. Linker combines objects and libraries into an executable
5. Loader maps the program into memory to run

## Examples

### Hello World (`hello_world.c`)

Your very first C program -- prints a message to the console:

```c
#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");
    return 0;
}
```

### Add Two Numbers (`add_two_numbers.c`)

A simple program that demonstrates functions, return values, and `printf` formatting:

```c
#include <stdio.h>

int add(int a, int b) { return a + b; }

int main(void) {
    printf("add(3,4) = %d\n", add(3,4));
    return 0;
}
```
