Hello World Program in C++ with Code::Blocks

After our last tutorial on C++ overview and general introduction, we will learn about the IDE we will use to write code in subsequent C++ tutorials.

If you are new to C++, there are so many available free and paid C++ IDE out there.

You can use any C++ IDE of your choice but we are going to use Code::Blocks to write our first hello world program and also in future tutorials.

Since we used the same IDE Code::Blocks in our C language programming tutorials, I have covered how to download and installed Code::Blocks but I will summarize the process here.


Code::Blocks is a multi-platform integrated development environment.

Code::Blocks comes in different versions. We are going to use the version with gcc compiler already packaged together.

  1. Go to Code::Blocks official website download page here.
  2. Click on download binary release.
  3. Select your Operating System


Once the Code::Blocks download is completed, it is time to start with the installation.

  • Go to where the .exe is downloaded.
  • Double click on the .exe file to initiate the installation process.
  • You will see the image below

Click on the Next Button. Follow the installation instructions until the end.

You can launch your newly installed CodeBlocks IDE to get a first glance on how it looks.

The next dialog that will appear is shown below. Within this time, codeblocks will check if it has detected any compiler.

If you have not installed or properly configured your compiler, it will show error notification – Compiler not detected.

When you see the image below without any error it implies that you have successfully installed codeblocks in your system.

Now that we are done with installing Code::Blocks, we are excited to write our first code in C++.

Create A C++ New Project

On start here page, click on create a project link and select the Console Application.

Click on the Go button and select C++ as programming language.

Add your project name and click on Done button to complete.

In the project folder, go to the source folder and open the main.cpp file.

You will see the code below on the page.

#include <iostream>

using namespace std;

int main()
    cout << "Hello world!" << endl;
    return 0;

The first line of the code is #include <iostream>. We will talk about preprocessor directive in later tutorial.

Preprocessor in C is a macro which provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.

This line is followed by using namespace std. In C++, any name that is not defined inside a class, function, or a namespace is considered to be part of an implicitly defined namespace called the global namespace.


Now that everything is set. Click on the run button or select build > run to execute the program.

You will see an output similar to what we have below.


We have been able to download and installed Code::Blocks for C++ development and we manage to write our first hello world program in C++, we will continue with a new topic in our next C++ tutorial.

If you have any questions about working with C++ kindly use the comment box below and drop your questions.

Posts you might be interested on:

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.