Skip to content
Laviyx Learn

Try

C course menu

Introduction to C Programming: What It Is, Where It Is Used, and Why Learn It

A beginner-friendly introduction to the C programming language: what C is, its history, where it is used (operating systems, embedded devices, databases, compilers), how C programs are compiled, how C compares with C++, Java and Python, and what you will learn in this course.

Beginner4 min readUpdated
On this page

C is a small, fast, general-purpose programming language. It gives you close control over the computer's memory and hardware, while still being far easier to write than assembly language. For more than fifty years it has been the language underneath much of the software the world depends on.

A first look#

Here is a complete C program:

hello.c (C)
#include <stdio.h>

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

Every C program starts running in a function called main. printf (from the standard input/output library, stdio.h) prints text. You will write and run this program yourself in First C Program.

A little history#

C was created by Dennis Ritchie at Bell Labs in the early 1970s, largely to write the Unix operating system. The book The C Programming Language by Brian Kernighan and Dennis Ritchie (1978) made it widely known. C is standardised by ISO; the versions are named after their years, such as C99, C11, C17 and C23. This course uses standard C that works with any modern compiler.

Where C is used#

AreaExamples
Operating systemsThe Linux kernel and large parts of Windows and macOS are written mainly in C
Embedded systemsMicrocontrollers in cars, washing machines, routers, medical devices and IoT sensors
DatabasesSQLite, PostgreSQL, Redis
Language runtimes and compilersThe reference Python interpreter (CPython) and many others
Networking and toolsWeb servers such as nginx, the git version control system, curl

Because so much infrastructure is written in C, it is essential for embedded and systems programming roles (see the Embedded Systems Engineer path), and many university courses start with it.

How C programs run#

C is a compiled language:

  1. You write source code in .c files.
  2. A compiler (such as GCC or Clang) translates it into machine code for your processor, producing an executable file.
  3. You run the executable directly. No interpreter or virtual machine is needed, which is one reason C programs are fast and small.

What makes C different#

  • Close to the hardware. You work directly with memory addresses through pointers.
  • Manual memory management. You request memory with malloc and must give it back with free; there is no garbage collector.
  • Small language. C has only a few dozen keywords. There are no classes, exceptions or built-in strings; you build those ideas yourself.
  • Few safety nets. Reading past the end of an array is not caught automatically. It can crash the program or silently corrupt data, as you will see in Undefined Behaviour.

This makes C powerful and educational: learning C teaches you how computers actually store and move data, which helps with every other language.

C compared with other languages#

CC++JavaPython
Runs asNative machine codeNative machine codeBytecode on the JVMInterpreted (bytecode)
MemoryManualManual plus smart pointersGarbage collectedGarbage collected
Classes and objectsNoYesYesYes
Typical useOS, embedded, systemsGames, systems, performance-critical appsEnterprise, AndroidScripting, data, web

C++ began as an extension of C, and most C code is also valid C++. If you later want classes, templates and a large standard library, continue with the C++ course.

What you will learn#

  1. Fundamentals: variables, types, operators, and input and output with printf and scanf.
  2. Conditions and loops.
  3. Functions, scope and recursion.
  4. Arrays and strings.
  5. Pointers, from the basics to function pointers.
  6. Dynamic memory and how to find memory bugs.
  7. Structs, unions, enums, linked lists, stacks and queues.
  8. Files, the preprocessor, multi-file programs, bitwise operators and error handling.

Key takeaway#

Finished this lesson?