Learn C Programming 03

03- C Programming Tutorials- Running the first C Program Leave a comment

Hello everyone and welcome back to the Blog. In this post, we are going to learn how to create and run our first C program in the Code Blocks Integrated Development Environment (IDE).

Creating a Project

To create and run programs in Code Blocks we first have to create a project. So the next question that comes to mind is; what is a project?

In simplest terms, a project can be thought off as a collection of different source files. A small project can also have a single source file.

To create a project:-

Go to File -> New -> Project. A wizard will be presented as shown in the following screenshot.


Select the Console application and click on Go.

Now a Console Application wizard is presented. Click on the Next button.


In the next window of the Console-Application wizard, a choice for language selection is presented which we would want to use for our project. As we are working on C programs so select C and press Next.


In the next window, we need to provide the project title; so for our case let’s give the title as “Hello World”. We also need to choose a folder path to where the project would be saved. After entering the path click on Next.


In the next window, we are able to select the compiler for our project. Select GNU GCC Compiler and leave all the other settings to their default state. Now click on finish to create the project along with some default code.


Once the project is created we will get a window similar to the screenshot below:

Now, if we double click on the Source folder present on the left-hand side under Workspace, we will find the main.c file. In every project, the execution always starts with the main.c file. If we click on the file we will find a default C program appear on the editor as shown in the screenshot.


This sample program will print “Hello world!” on the output window when compiled and run. We will get into the details of how this happens in the later chapters. For now, let us compile and run this program and see what happens.

First of all, to compile the program we can select Build->Build, form the menu as shown in the screenshot below or press Ctr+F9 from the keyboard.


If there are no compilation errors in our program then we will get a message like this in the Logs tab.


Now, to run the Program select Build->Run from the menu or press Ctr+F10 from the keyboard.


A new output window appears in the IDE with the results.


That’s it for this post, in the next one we would look into the basic elements of a C program.

If you want to learn about microcontrollers and other electronics projects, I would ask you to visit our YouTube channel and subscribe to receive continuous notifications. You can also subscribe to our Newsletter below to get email notification of each post as and when they are posted.

You can also follow us on social media platforms such as  Facebook and Twitter.

Thanks a lot for reading through this post. Feel free to follow through this series and comment your queries in the comment box below. Also feel free to contact us regarding any out of stock product and we will try to get back to you as soon as possible.

Leave a Reply