Skip to main content

Featured Post

Ultimate Guide: C++ Setup in Visual Studio Code (VS Code)

Ultimate Guide: C++ Setup in Visual Studio Code (VS Code)

Ultimate Guide: C++ Setup in Visual Studio Code (VS Code)

if you Want to write and run C++ code in Visual Studio Code, but not sure how to setup vs code for c++? in this blog article i tell you how to install c++ in vscode


Step-by-Step process for How to Set Up C++ in VS Code

Ultimate Guide: C++ Setup in Visual Studio Code (VS Code)



Step 1: First we have to Download & Install Visual Studio Code

 For Install VS code You have to Go to: [(https://code.visualstudio.com)

 Download for your OS according to your device (Windows, Mac, Linux)

 Install like a normal app

 

Step 2:Now we have to Install a C++ Compiler

 C++ needs a compiler to run our code.

For Windows Use MinGW-w64 (a popular C++ compiler for Windows)

you can Download from:

https://www.mingw-w64.org/](https://www.mingw-w64.org/


Steps:

1. Run the installer and choose the architecture for 32 bit or 64 bit according to your device

2. Install it in a folder 

3. now you have to go in this folder then bin and copy the path 


Step 3: We have to Add Compiler to System PATH (Windows)

 How to Add MinGW to PATH f (Windows):

1. First Open the Start menu, search for → `Environment Variables`

2. Click on "Edit the system environment variables"**

3. In the window, click the button → "Environment Variables"

4. Under System variables, find → `Path` → Click Edit

5. Click New and paste in the path to your `bin` folder.

For example:

C:\Program Files\mingw-w64\...\bin

   

6. Click OK, OK, OK.


And Our Setup of VS code is almost done

 Now open a new terminal and type:

 g++ --version

You should see the version info, it means it works!

vs code setup for c++ in macOs:

Just open Terminal and run this command for Confirms it installation XCode-select --install

This installs Apple’s official C++ tools, including `clang`


  •  Setup For Linux (Ubuntu) for Vs code 

For Ubuntu user You have to go In Terminal type this command

sudo apt update && sudo apt upgrade -y

sudo apt install -y build-essential gdb


This Will install tools like `g++`, `gcc`, `make`, and other tools.

 

Step 4:Now We have to Install C++ Extension in VS Code

1.First Open VS Code

2. Go to the left sidebar → Click Extensions (or press shortcut for `Ctrl+Shift+X`)

3. Search: `C/C++`

4. Install the one by Microsoft

This gives us features like IntelliSense, debugging, and more.


Step 5:now how we can create our first c++ program


1. First We have to Make a new folder (e.g., `my-cpp-project`)

2. in that folder create a file: `first.cpp`


Write this code

cpp

#include <iostream>

using namespace std;


int main() {

    cout << "Hello, C++ in VS Code!" << endl;

    return 0;

}


Step 6: Set Up Build Task to Compile Your Code


Let’s make it easy to compile your code with one shortcut.


1. In VS Code, go to the top menu:

   TerminalConfigure Default Build Task

2.You have to go and choose: C/C++: g++ build active file


It will help us for auto-create a `.vscode` folder with a `tasks.json` file.


Now press `Ctrl + Shift + B` → This help us for builds (compiles) our code!


Step 7: For Run our Program

After compiling, a new file will be created:

 1.On Windows → `main.exe`

 2.On Linux/macOS → `a.out`


for run it:

Open Terminal in VS Code, then type:

./main.exe ← for

 Windows  

./a.outfor Linux/macOS

You’ll see output:

Hello, C++ in VS Code

Frequently asked questions:

1.how to check mingw installed or not in cmd.

Ans:To Check Mingw installed or not in cmd open a new terminal and type:g++ --version

If You see the version info, it means it works!

2.how to setup vs code for c++ in ubuntu

Ans:For Ubuntu user You have to go In Terminal type this command

sudo apt update && sudo apt upgrade -y

sudo apt install -y build-essential gdb

This Will install tools like `g++`, `gcc`, `make`, and other tools.

Conclusion: Here in this blog Article I have share how to setup or install Visual studio for Windows Macbook and Ubuntu for C++ and How to write Your first C++ program in Visual studio And also Some Shortcut also to Run Code on Visual Studio I hope You Like Our Article.



Comments

Popular posts from this blog

The Easiest Way to Learn Coding for Beginners (Step-by-Step Guide)

The Easiest Way to Learn Coding for Beginners (Step-by-Step Guide) You want to learn coding but don’t know where to start from. I will tell you how you can learn coding easily as a beginner. Coding is an important skill today. You should know why you want to learn a coding language. If you want to make a website, app, or software, learning coding gives you confidence as a beginner. Let’s discuss some step-by-step ways to learn coding. Step 1: Don’t think coding is so hard Don’t assume in your mind that coding is hard or tough to learn. Coding is a skill everyone can learn by practice, like learning a language or a musical instrument. Don’t compare your beginning with someone else’s middle. Mistakes are part of learning. Step 2: Choose any beginner-friendly programming language As a beginner, you can choose some of the languages like Python, C, or Java. Choose a language you find easy because starting with an easy programming language gives you confidence during the beginner phase of le...

How to Start DSA as a Beginner (2025 Guide): A Fresh and Actionable Roadmap

How to Start DSA as a Beginner (2025 Guide): A Fresh and Actionable Roadmap You have to start learn Data Structures and Algorithms (DSA) ?. DSA is the backbone of problem-solving in computer science and coding interviews. if you're a college student or a developer, this beginner's guide gives a beginner-friendly approach to get you started with DSA in 2025 — with fresh strategies that actually work. What is DSA and Why Should Beginners Care? Data Structures and Algorithms (DSA) it is impotant for writing efficient code. From product-based company interviews to backend development and system design — mastering DSA is a Very good for you. Importance of Dsa: Boosts problem-solving skills important for coding interviews you can become better developer Step-by-Step ways: How to Start Learning DSA as a Beginner 1 . Build a Solid Programming basics Before diving into DSA, you should know at least one programming language c++,python or java Quick Tips: you can Focus on syntax, loops, c...

Best coding projects for beginners to start their coding journey

Best coding projects for beginners to start their coding journey. Projects improve your coding skills and also enhance your logical thinking. In this blog article, I have provided coding projects for beginners that will definitely level up your coding skills. 1. Basic CGPA Calculator App You can start this project by understanding basic concepts like variables, operators, and functions. This is one of the most suitable beginner projects that will spark your interest in coding. It builds your confidence because the difficulty level is not too high. 2. Daily Task Management This is also a useful and beginner-friendly coding project. It is not too hard, but you should focus on the algorithm and requirements. Since it can be used in your daily life, it is a practical choice for new coders. 3. School Schedule App for Every Student This is another helpful project for beginners because it can be used by your school or college. It allows students to view their schedules easily. You can start t...