# How to Set Up VS Code for C and C++ Programming on Windows (Step-by-Step Guide)

# How to Set Up VS Code for C and C++ Programming on Windows (Step-by-Step Guide)

Want to start coding in **C** or **C++** using **Visual Studio Code (VS Code)**?  
You’re in the right place. In this step-by-step guide, I’ll show you **how to set up VS Code with MinGW (GCC Compiler)** to write, compile, and run your C/C++ programs easily.

**Perfect for:**

* Beginners
    
* College students (BCA, [B.Tech](http://B.Tech), Diploma)
    
* Anyone who wants a lightweight coding setup
    

## 🚀 Step 1: Download and Install VS Code

1. [Download VS Code](https://code.visualstudio.com/)
    
2. Install it on your system like any normal app.
    

## ⚙️ Step 2: Download and Install MinGW (GCC Compiler)

1. [Download MinGW](https://sourceforge.net/projects/mingw/)
    
2. During installation, make sure you select:
    
    * `mingw32-gcc-g++`
        
    * `mingw32-gcc-gcc`
        
3. Install it to `C:\MinGW`
    

## 🛠️ Step 3: Setup Environment Variables

1. Control Panel → System → Advanced System Settings → Environment Variables
    
2. Find **Path** → Click Edit
    
3. Add this path:
    
    C:\\MinGW\\bin
    
    ## 🧩 Step 4: Install C/C++ Extension in VS Code
    
    1. Open VS Code
        
    2. Go to **Extensions (Ctrl+Shift+X)**
        
    3. Search and install **C/C++ by Microsoft**
        
    
    ## 💻 Step 5: Write Your First C Program
    
    ```c
    #include <stdio.h>
    
    int main() {
        printf("Hello, World!\n");
        return 0;
    }
    ```
    
    ## 🏁 Step 6: Compile and Run
    
    1. Open **Terminal (Ctrl+\`)**
        
    2. Compile the program:
        
    
    ```bash
    gcc filename.c -o output.exe
    ```
    
    3. Run the program:
        
    
    ```bash
    ./output.exe
    ```
    
    ## ⚡ Bonus Tip: tasks.json for Easier Compilation
    
    ```json
    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build and run",
                "type": "shell",
                "command": "gcc",
                "args": ["${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "&&", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
                "problemMatcher": ["$gcc"]
            }
        ]
    }
    ```
    
    Now just press **Ctrl+Shift+B** to compile and run automatically.
    
    ## 🎯 Conclusion
    
    Now you’re fully set to code, compile, and run C/C++ programs on Windows using VS Code. 🔥
    
    **Need help? Drop a comment here or check my** [**YouTube channel**](https://youtube.com/@codewithmishu) for the video version of this tutorial.
    
    ---
    
    ### 📚 More Coming Soon:
    
    * **C Programming Masterclass Playlist (2025 Edition)** → Subscribe on YouTube for updates
        
    * **C Projects for Beginners**
        
    * **C to C++ Full Roadmap**
        
        ### 🔔 **Connect with Me:**
        
        * 🌐 **All My Links:** [https://codewithmishu.vercel.app/](https://codewithmishu.vercel.app/)
