Setting Up C++ Environment

Writing your first C++ Program

Before learning about C++, it is important to deploy an IDE on your local machine.IDE stands for Integrated Development Environment. It is simply a UI, which helps to type syntax easily, debug and run the program.

C++ runs on lots of Operating System like Windows, Linux, Mac,Unix,etc.

It is widely encouraged for general purpose programming as well as Competitive level also. In this section, you will learn about Setting up C++ on your local machine and writing an easy Hello World Program.

If you don’t want local setup then you can go online IDE, which you can use to run program and compile it easily. The link for some famous online IDE is given below this article. It’s not important to go with IDE, you can go with any text editor also, just save the file with (.cpp) or (.c) extension at the end. After that, you can go with any compiler to execute your file.

For Windows :

Some of the famous IDE like DevC++ , Code::Blocks, Eclipse, Visual Studio, Atom, etc.  See the image below of DevC++ IDE

Click on File menu–> New File and name this any empty file with .cpp extension.

After this you can run your file by going to Build menu and choose the Build and Run option.

For Linux :

Installing C++ environment is very easy in linux also. You have to only type these commands on your console.

Open Terminal Window and type these commands

  • sudo apt-get update
  • sudo apt-get install GCC   

 This will install GCC compiler on your local machine. After this type,

  • sudo apt-get install build-essential

After this command, you can check whether your GCC is installed properly or not by checking it’s version info. For this, type the below command

  • g++ –version

If no errors are shown, then your compiler is ready. Now you can compile both C and C++ programming languages. You can run a file in (.cpp) by typing this command:

  • g++ helloworld.cpp

 And then press enter to compile the file

If no errors are found during compilation, then you can see the output on terminal by this command

  • ./a.out          (dot slash a dot out)

For Mac OS :

Mac users have to download a software called xcode. You can either search it on google or by clicking this link 

After downloading and installing successfully, you need to create a new project on File menu option, and then click on New file and create a new file with (.cpp) extension, if not present. After this you might get some predefined

Writing the first simple Helloworld program in C++

Type this simple code for getting output

using namespace std;
int main(){
   cout<<”Hello World ! This is my first program in C++”;
   return 0;

Output :  Hello World ! This is my first program in C++

If you get the similar output, then Congratulations! You have setup your C++ environment successfully.

Facebook Comments

Show More

Leave a Reply

Back to top button