Step 1 : Install g++

g++ is a unix/linux based c++ compiler usually operated via the command line.

To install g++ run the following command in terminal.

sudo apt-get install g++

After installation you can check whether it has has been installed correctly or not by running following command in terminal

g++ -v

Step 2 : Write the program

Write the following simple “Hello World” program in your favorite text editor and save it as “hello.cpp”

int main(){
    std::cout<<"Hello World"<<std::endl;
    return 0;

Step 3 : Compile the program

Open a terminal and move to the directory where you saved your “hello.cpp”

Run the following command to compile the code.

g++ hello.cpp -o hello

Step 4: Run the program

After compiling the code, in the same directory run the following command to run your Hello World Program.


It will give the following output in terminal

Hello World