Set up VS Code for C++

This is the first post of my C++ series which will cover all the topics you will need as a beginner and will guide you to an advanced level and get you prepared for the journey of Competitive programming.

Photo by Danial Igdery on Unsplash

Downloading GCC compiler

For Windows
https://sourceforge.net/projects/mingw/
1. Run the installer the following window opens.

2. Click on install.

3. Click on continue, it will download some files once downloaded continue.

4. Select mingw32-base-bin, mingw32-gcc-g++-bin, and msys-base. Click on installation and apply changes. The MinGW installation is complete.

5. By default MinGW will be installed in C: drive. You have to add the location to Path. Copy the path C:\MinGW\bin, search environment variables, and open it. Select Path in system variables and click edit, click new, and add MinGW path there. Click ok and close it.

6. Open Command prompt and type g++ — version. you should see the version of g++ installed means the installation is successful.

For Linux(Ubuntu)

Open the terminal and paste the following commandssudo apt-get update
sudo apt-get upgrade
sudo apt-get install g++
gcc --version

Setting up VS Code

Download VS Code from the link https://code.visualstudio.com/

Open VS Code and click on the extensions icon in the sidebar. Search for C++ extension from Microsoft and Code runner and install them.

Just one last step before you can run your own C++ programs.

Open settings(Ctrl + ,) and click extensions. Select Code runner and check Run in terminal.

Congratulations! You are all set.

Open any folder in the editor and create a new file hello.cpp and paste the following code.

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World!"<<endl;
return 0;
}

Hit Ctrl+Alt+N or click on the Run button to run the code. You should see the output Hello World! on the terminal.

That’s all folks!

Read about the basics of Cpp program here: https://niftynitin.medium.com/basics-of-c-633668d842d8

I am a CS graduate and an ML enthusiast. My purpose here is to guide beginners in their programming and Machine learning journey.