Let’s create our First Program in C

Welcome back to Think & Free. This is another episode of Express Learning Programming with GNU C Programming Language. In the previous lesson, we talked about all the basic concepts and other basic things about the GNU C Programming language. This lesson, We are going to take a look at how to make our first C Program, and how to compile and run It.

We need some source code editor/text editor program to create our program. In Microsoft Windows, we can use Notepad for it. If You are Linux or Mac User you can use another editor. No matter what is it. Let’s begin building our first C Program.

Related Article: Top 5 Useful Extensions for VS Code Editor

Building “Hello, World” Program

In our first Project in C, let’s try to print a simple “Hello, World” string on our console window. Hello, World source code is down below.

#include <stdio.h>
int main()
    printf("Hello, World\n");
    return 0;

Now open up your favorite editor write down the given code using your favorite text editor and save it. Don’t forget to save it with the .c extension. It’s the extension for C Language source files.

C Header files come with a .h extension.

Let’s break down this code to understand. At the first line of code #include <stdio.h>. stdio.h. This line describes including preprocessor headers in the program. This header is an important header for every C Project. In future lessons, I will talk about all things about headers. next, we can see our program entry point. It is the main function. int main(){} is our program entry point. In the previous lesson, I told you, that the main function is the beginning of any Program, written in C. Let’s see what is inside our main function.

The Printf(); Function

printf("Hello, World\n");

printf("Hello, World\n"); printf(); It is one of a function of C used to get a print of some string, character, or, some other type of data in the console window. “Hello, World” is a String, constant. if something inside double quotes, GNU C Programming Language will it was a string type of data. In our future lessons, I will tell why I’m called it was a String, constant. Keep it on your mind I will explain later.

See every C Statement ends with a semicolon (;). It was another main thing about GNU C Programming Language. Keep in mind your every C Statement must end with a semicolon.

At the end of Hello, World\n“, See something special. it was a “\n”. What is that? In C these types of things are called an escape sequence. These type of things is used to print some special character in C. For example, “\n” is used to get a new line after printing something. In future tutorials, I will explain more about the escape sequence.

at the last, return 0; Return Value will indicate what is the returning point or end-state of some function or our program. 0 means returning without any errors.

Latest Article: Top 5 Linux Distros in 2023, Let’s Learn about Linux

Compile & Run Our First C Program

Finally, our program must be compiled before running. in our previous lesson, We mentioned C is a Compiled Programming Language, and I told you we need some Compiler program to compile our Source Code before executing it. Now in this lesson series, we are using The GNU GCC Compiler for Compile This Program. In the previous lesson, I told you about the GNU GCC Compiler.

First, save the project as a C Source file you can use any filename it’s no matter but, don’t forget to use “.c” as a source file extension. Once done saving process. We can use the following commands to compile your C Source Code to Compile a Binary file.

gcc source_filename.c -o executable_filename
  • source_filename – Our C Source Filename.
  • executable_filename – That means the name for our compiled binary file. gcc -o means output.

This is the way to compile C Source Code or C Source file to Executable File. After Compilation is done, now you can run this executable file on your system. In Linux systems before running this executable, you must set the file permission on your system. Let’s check how to set up file permissions on your Linux System.

chmod +x executable_filename

chmod means Change Mode. This command will set execution permissions on your system in your file. Done setting up permissions now you can execute.


In Windows, you may not need to set file permissions. you can simply type your executable_filename and hit enter Now the result will be displayed. Looks like this.


If you have some questions, leave a comment. Hope you guys enjoy this tutorial see you back soon in another Episode of Express Learning Programming with GNU C Programming Language.

1 thought on “Let’s create our First Program in C”

Leave a Comment