Labs ICT
Pro Login

Get Started

Before you can write C, you need a compiler. A compiler is a program that turns your C source code into an executable file. The most common C compiler is GCC — the GNU Compiler Collection.

If you are on Linux, GCC is probably already installed. Open a terminal and type gcc --version to check. On macOS, you can get it through Xcode Command Line Tools. On Windows, the easiest option is MinGW or use an online C compiler — this tutorial has a "Try it Yourself" button on every example.

Your First C Program

Let me show you the classic first program. Every programmer writes this one. It is a tradition.


#include 

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

Save that code in a file called hello.c. The .c extension tells the world this is C source code.

Compiling and Running

Open your terminal in the folder where you saved hello.c and run:

gcc hello.c -o hello

This tells GCC to compile hello.c and output an executable named hello. If there are no errors, you will have a new file in your folder.

Now run it:

./hello

On Windows, it would be hello.exe and you just type hello.

You should see:

Hello, World!

That is it. You just compiled and ran your first C program. Welcome to the club.

Try it Yourself →