🟢 Beginner  ·  Lesson 03

Setup Environment (GCC, Dev-C++)

Environment Setup

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

C Programs लिखने के लिए क्या चाहिए?

C programs लिखने और run करने के लिए आपको दो चीज़ें चाहिए:

  1. Text Editor या IDE — जहाँ आप C code लिखते हैं (source code)
  2. C Compiler — आपके C code को machine language (executable) में convert करता है

सबसे popular C compiler है GCC (GNU Compiler Collection) — यह free, open-source है और सभी platforms पर available है।

✅ सबसे Quick Option – बिना Installation के

https://www.onlinegdb.com/online_c_compiler पर जाएं — C language select करें और code directly browser में run करें। Practice के लिए perfect।

Windows पर Setup (Dev-C++)

Method 1: Dev-C++ (Beginners के लिए सबसे आसान)

  1. https://sourceforge.net/projects/orwelldevcpp/ पर जाएं
  2. Download पर click करें और installer run करें
  3. Installation के दौरान सभी defaults accept करें
  4. Dev-C++ खोलें → File → New → Source File
  5. C code लिखें → hello.c नाम से Save करें
  6. F9 press करें या Execute → Compile & Run click करें

Method 2: Code::Blocks (Recommended)

  1. http://www.codeblocks.org/downloads/binaries/ पर जाएं
  2. Download: codeblocks-XX.XXmingw-setup.exe (जिसके नाम में mingw हो — इसमें compiler included है)
  3. Installer run करें → Full installation select करें
  4. Code::Blocks खोलें → File → New → Empty File → hello.c नाम से Save करें
  5. Code लिखें → F9 press करके Build and Run करें

Linux पर Setup (Terminal + GCC)

Terminal
gcc --version           # Check if GCC installed है
sudo apt install gcc    # Install करें (Ubuntu/Debian)
gcc hello.c -o hello    # Compile करें
./hello                 # Run करें

VS Code Setup

  1. https://code.visualstudio.com/ से VS Code download करें
  2. Extensions में C/C++ by Microsoft install करें
  3. Windows पर MinGW-w64 install करके PATH में add करें
  4. Terminal में: gcc filename.c -o output

पहला Compilation – Step by Step

hello.c
#include <stdio.h>

int main() {
    printf("Namaste Duniya!\n");
    return 0;
}
Namaste Duniya!

Compilation process के 4 stages होते हैं:

  1. Preprocessing#include और #define handle करता है
  2. Compilation — C को assembly code में convert करता है
  3. Assembly — assembly को machine code (object file) में convert करता है
  4. Linking — libraries को link करके final executable बनाता है

सारांश

  • C लिखने के लिए compiler (GCC) और editor/IDE चाहिए
  • Beginners: Windows पर Dev-C++ या Code::Blocks use करें
  • Online practice: OnlineGDB.com (कोई installation नहीं)
  • Professional: VS Code + GCC
  • Compile command: gcc filename.c -o outputname
← Back to C Tutorial