Setup Environment (GCC, Dev-C++)
Environment Setup
What You Need to Write C Programs
To write and run C programs, you need two things:
- A Text Editor or IDE — Where you write your C code (source code)
- 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.
| Tool | Type | Platform | Recommended For |
|---|---|---|---|
| Dev-C++ | IDE | Windows | Absolute beginners, school/college students |
| Code::Blocks | IDE | Windows, Linux, Mac | Beginners to intermediate |
| VS Code + GCC | Editor + Compiler | All platforms | Intermediate to advanced, professionals |
| gcc (terminal) | Compiler | Linux/Mac | Advanced, B.Tech students |
| OnlineGDB | Online IDE | Browser | Quick testing, no installation needed |
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.
- Go to:
https://sourceforge.net/projects/orwelldevcpp/ - Click Download and run the installer
- Accept all defaults during installation
- Open Dev-C++ → File → New → Source File
- Write your C code → Save as
hello.c - Press F9 or click Execute → Compile & Run
Method 2: Code::Blocks (Recommended)
- Go to:
http://www.codeblocks.org/downloads/binaries/ - Download:
codeblocks-XX.XXmingw-setup.exe(the one with mingw in name — this includes the compiler) - Run installer → select Full installation
- Open Code::Blocks → File → New → Empty File → Save as
hello.c - Write code → Press F9 to Build and Run
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:
gcc --version
If not installed, install it:
sudo apt update sudo apt install gcc
Write a C file, then compile and run:
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
- Open VS Code → click Extensions icon (left sidebar)
- Search: C/C++
- Install the extension by Microsoft
Step 3: Install GCC (Windows)
- Download MinGW-w64 from:
https://winlibs.com/ - Extract and add the
binfolder to your system PATH - Verify: open Command Prompt → type
gcc --version
Step 4: Compile via Terminal in VS Code
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:
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
The compilation process has 4 stages:
- Preprocessing — handles
#includeand#define - Compilation — converts C to assembly code
- Assembly — converts assembly to machine code (object file)
- 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 करने के लिए आपको दो चीज़ें चाहिए:
- Text Editor या IDE — जहाँ आप C code लिखते हैं (source code)
- C Compiler — आपके C code को machine language (executable) में convert करता है
सबसे popular C compiler है GCC (GNU Compiler Collection) — यह free, open-source है और सभी platforms पर available है।
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 के लिए सबसे आसान)
https://sourceforge.net/projects/orwelldevcpp/पर जाएं- Download पर click करें और installer run करें
- Installation के दौरान सभी defaults accept करें
- Dev-C++ खोलें → File → New → Source File
- C code लिखें →
hello.cनाम से Save करें - F9 press करें या Execute → Compile & Run click करें
Method 2: Code::Blocks (Recommended)
http://www.codeblocks.org/downloads/binaries/पर जाएं- Download:
codeblocks-XX.XXmingw-setup.exe(जिसके नाम में mingw हो — इसमें compiler included है) - Installer run करें → Full installation select करें
- Code::Blocks खोलें → File → New → Empty File →
hello.cनाम से Save करें - Code लिखें → F9 press करके Build and Run करें
Linux पर Setup (Terminal + GCC)
gcc --version # Check if GCC installed है sudo apt install gcc # Install करें (Ubuntu/Debian) gcc hello.c -o hello # Compile करें ./hello # Run करें
VS Code Setup
https://code.visualstudio.com/से VS Code download करें- Extensions में C/C++ by Microsoft install करें
- Windows पर MinGW-w64 install करके PATH में add करें
- Terminal में:
gcc filename.c -o output
पहला Compilation – Step by Step
#include <stdio.h> int main() { printf("Namaste Duniya!\n"); return 0; }
Compilation process के 4 stages होते हैं:
- Preprocessing —
#includeऔर#definehandle करता है - Compilation — C को assembly code में convert करता है
- Assembly — assembly को machine code (object file) में convert करता है
- 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