WeCodeAcademy

C Introduction

C is a fast, small, powerful language created in the 1970s. Operating systems, databases, game engines and the firmware inside devices are written in C, and many other languages (C++, Java, C#, JavaScript) borrowed its syntax.

A C program is compiled to machine code before it runs. Here is the classic first program:

ExampleC
#include <stdio.h>

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

#include <stdio.h> loads the input/output library. main is where the program starts. printf prints text, and \n is a new line. Returning 0 tells the system the program finished normally. To try an example yourself, save it as main.c, compile with gcc main.c -o main and run ./main. The output under each example is the real output from running it.

Quick check

Which function prints text in C?

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.