Follow the below steps to build your first program in CODE::BLOCK
- Click on the start button and move to all programs or you can pick the shortcut icon of the program installed from the desktop.
- After the application has been launched, go to File and click
- Move the pointer to new and single-click
- Click on Project, which is creating a new project
- Select and click on the console application
- Ensure to choose C++ as the language, however, the GNU GCC Compiler
- Make sure to choose or select a project name
- Also, do not forget the project location
Writing Your First C++ Code in CODE::BLOCKS
In the application window, that is code::block interface, you will see a project tree by default on the left-hand side, however, a code editor in the centre and also, a toolbar at the top as usual.
In addition, that is in the code editor, you will also see a default main.cpp this is the location where you will be writing your CPluPlus code.
Ensure to delete the existing code in the above location, that is the MAIN.CPP and write your preferred code in there.
For example:
How to write hello world. Line 1: #include <iostream> Line 2 Line 3 Int main( ) { Line 4 Std::cout << “Hello, World!” << std::endl; Line 5 return 0; Line 6 }
In summary, the above codes are accurate and known to be the main basics when beginning code building in CPP or C++ for the first time.
HOW TO COMPILE THE CODE
- Click on the build button from the main toolbar on top of the window/ you can also press the Function key 7 to perform the same action.
- If there are no errors, you are good to go.
- Next, click on the RUN button from the same toolbar right after the build button
Result:
You should see the output as “Hello, World!” in the known application console in a different window.
About Author
Discover more from SURFCLOUD TECHNOLOGY
Subscribe to get the latest posts sent to your email.