🟢 Beginner  ·  Lesson 03

Setup Environment (GCC, Dev-C++)

What You Need to Write C Programs

To write and run C programs, you need two things:

  1. A Text Editor or IDE — Where you write your C code (source code)
  2. A C Compiler — Converts your C code into machine language (executable)

The most popular C compiler is GCC (GNU Compiler Collection) — it's free, open-source, and available on all platforms.

ToolTypePlatformRecommended For
Dev-C++IDEWindowsAbsolute beginners, school/college students
Code::BlocksIDEWindows, Linux, MacBeginners to intermediate
VS Code + GCCEditor + CompilerAll platformsIntermediate to advanced, professionals
gcc (terminal)CompilerLinux/MacAdvanced, B.Tech students
OnlineGDBOnline IDEBrowserQuick testing, no installation needed
✅ Quickest Option – No Installation

Go to https://www.onlinegdb.com/online_c_compiler — select C language and run code directly in your browser. Perfect for practicing while you learn.

Setup on Windows (Dev-C++)

Method 1: Dev-C++ (Easiest for Beginners)

Dev-C++ is a free IDE that includes the MinGW GCC compiler. One installer, ready to go.

  1. Go to: https://sourceforge.net/projects/orwelldevcpp/
  2. Click Download and run the installer
  3. Accept all defaults during installation
  4. Open Dev-C++ → File → New → Source File
  5. Write your C code → Save as hello.c
  6. Press F9 or click Execute → Compile & Run

Method 2: Code::Blocks (Recommended)

  1. Go to: http://www.codeblocks.org/downloads/binaries/
  2. Download: codeblocks-XX.XXmingw-setup.exe (the one with mingw in name — this includes the compiler)
  3. Run installer → select Full installation
  4. Open Code::Blocks → File → New → Empty File → Save as hello.c
  5. Write code → Press F9 to Build and Run
⚠️ Important

Always download the Code::Blocks version that includes mingw in the filename. Without mingw, you get the IDE but no compiler!

Setup on Linux (Terminal + GCC)

GCC is usually pre-installed on Linux. Check with:

Terminal (Bash)
gcc --version

If not installed, install it:

Ubuntu/Debian
sudo apt update
sudo apt install gcc

Write a C file, then compile and run:

Terminal
nano hello.c          # Write your C code
gcc hello.c -o hello  # Compile: creates 'hello' executable
./hello               # Run the program

VS Code Setup (Best for Long-Term Use)

Step 1: Install VS Code

Download from https://code.visualstudio.com/ — free for all platforms.

Step 2: Install C/C++ Extension

  1. Open VS Code → click Extensions icon (left sidebar)
  2. Search: C/C++
  3. Install the extension by Microsoft

Step 3: Install GCC (Windows)

  1. Download MinGW-w64 from: https://winlibs.com/
  2. Extract and add the bin folder to your system PATH
  3. Verify: open Command Prompt → type gcc --version

Step 4: Compile via Terminal in VS Code

VS Code Terminal
gcc hello.c -o hello -Wall  # -Wall shows all warnings
./hello                      # Linux/Mac
hello.exe                    # Windows

Your First Compilation – Step by Step

Let's write, save, compile and run your first C program:

hello.c
#include <stdio.h>

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

The compilation process has 4 stages:

  1. Preprocessing — handles #include and #define
  2. Compilation — converts C to assembly code
  3. Assembly — converts assembly to machine code (object file)
  4. Linking — links libraries and creates final executable

All 4 steps happen automatically when you run gcc hello.c -o hello.

Summary

  • You need a compiler (GCC) and an editor/IDE to write C
  • Beginners: use Dev-C++ or Code::Blocks on Windows
  • Online practice: use OnlineGDB.com (no installation)
  • Professional setup: VS Code + GCC
  • Linux users: GCC is usually pre-installed or sudo apt install gcc
  • Compile command: gcc filename.c -o outputname

Frequently Asked Questions

How do I set up C on Windows?
The easiest way is to install a compiler such as MinGW (which provides gcc) or an all-in-one IDE like Code::Blocks that bundles the compiler. After installing, you write your code in a .c file and compile it from the terminal or the IDE's build button.
What compiler should a beginner use for C?
gcc is the most popular free C compiler and works on Windows, Linux and macOS. Beginners often use it through an editor like VS Code or an IDE like Code::Blocks, which handle the compile-and-run steps with a single click.
Do I need to install anything to write C programs?
To compile and run C on your own computer you need a compiler such as gcc. If you only want to try C quickly, online compilers let you write and run code in the browser without installing anything, which is great for learning the basics first.
How do I compile and run a C program from the terminal?
Save your code in a file like hello.c, then run gcc hello.c -o hello to compile it into a program called hello, and run it with ./hello on Linux or macOS, or hello.exe on Windows.
Is VS Code good for C programming?
Yes. VS Code is a free, lightweight editor that, combined with the C/C++ extension and a compiler like gcc, gives a comfortable setup for writing, compiling and debugging C. It is a popular choice for both beginners and professionals.
← Back to C Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.