CodeMIRAI
0 XP

Introduction to C

2 min read 1 runnable example Quiz included

C is a programming language created by Dennis Ritchie at Bell Labs in the early 1970s to build the Unix operating system. It is small, fast and close to how the computer actually works, and it's still everywhere: operating systems (Linux, Windows' core), databases, embedded devices, game engines, and the interpreters of other languages, including Python itself.

Why learn C?

  • You learn how computers really work: memory, addresses, how data is laid out.
  • Speed: C programs run very close to the speed of the hardware.
  • Foundations: C++, Java, C#, JavaScript and many others borrow C's syntax, so C makes them easier to learn.

Software you use every day is written in C:

ProgramWhat it is
Linuxthe kernel under Android, most web servers and nearly every supercomputer
CPythonthe standard Python interpreter
SQLitethe database inside phones, browsers and countless apps
Gitthe version control nearly every developer uses
Redisa very fast in-memory database

A first look

C
#include <stdio.h>

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

Press Run. Every line has a job, which the next lesson takes apart piece by piece.

Compiled, not interpreted

C is a compiled language. Before a C program can run, a compiler (such as GCC or Clang) translates the whole source file into machine code, producing an executable file:

Terminal
gcc hello.c -o hello     # compile
./hello                  # run the result

The compiler checks the whole program first, so many mistakes are caught before the program ever runs.

Finished this lesson?Mark it complete to earn +20 XP and move your progress on.