How to Write C++ Code Using Code::Blocks

In the previous article, we briefly covered how to download Code::Blocks. This article will explain how to write a C++ program using Code::Blocks.First, launch the Code::Blocks software. Then, click on the "New File" option.

2025120302_g2gsh.png

Then click on the "Empty file" option.

2025120303_4hs.png

Then enter the following code:

#include<iostream>
using namespace std;
int main(){
    cout<<"hello world";
    return 0;
}

After entering the code, your Code::Blocks interface will look like this:

2025120304_h1gb09a.png

After entering the above code, go to the "Build" menu and select the "Build" option.

2025120305_30n2va.png

The first time you do this, you’ll need to save the file because it hasn’t been saved yet. Change the file extension to .cpp (the standard extension for C++ files) and click the "Save" button.Once the file is saved, go to the "Build" menu again and select the "Run" option.

2025120307_4gg1va.png

And then you’ll see that the code runs successfully!

2025120308_23gh.png

Subscribe to CodeEachDay

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe