Getting started with C

Your first program, compiling it, and printing values.

C gives you direct control over memory and runs fast with very little overhead, which is why operating systems and device firmware use it. Learning it teaches you how a computer really works.

Save this as main.c, compile with gcc main.c -o main, and run ./main.

C
#include <stdio.h>

int main(void) {
  printf("Vanakkam, C!\n");
  printf("%d + %d = %d\n", 2, 3, 2 + 3);
  return 0;
}
Output
Vanakkam, C!
2 + 3 = 5
FormatPrints
%dint
%fdouble, with %.2f for two decimals
%cchar
%sA string
%pA memory address
Types and operators โ†’