C Language “hello world” Program Explained Step by Step All Statements

C “hello world” program

While learning programming languages it is common to first learn to print “hello world” on the screen. It is because this is an easy program to start with learning a programming language. In this article, I will explain the statements one by one used in writing the “hello world” program in the C programming language.

If you do not know what is C programming language you can learn about it on Wikipedia.

Table of Contents:

Hello World Program using Printf()

#include <stdio.h>

int main()


printf("hello world");

return 0;


hello world program in C language
Note: green colored words are defining statements
of the program and are not included in the program

#include <stdio.h>

This statement has two parts you need to understand. The first one is #include <>. It is used to add a header file to a program. To include user-defined files or standard files in a program #include is mostly used at the top of the program. Like in the above example #include<standard_files> is used for including a standard C file. If you need to add a user-defined file then we will use #include as #include “user-defined_file”.

The preprocessor reads the directive and then commands it to insert the Standard header file or user-defined file. In the above case of printing “hello world,” program stdio.h is used which is a standard header file of C.

Now, what are standard files or header files? Well, C function declarations and macro definitions are contained by header files so they can be shared between many source files. header files have .h extension and you can include them, by using preprocessor directive #include. In the above example, we have used stdio.h header file.

stdio.h header file is used to include input/output functions in the program. The printf() function we have used in the above program is a standard function. printf() is included (predefined) in stdio.h header file.

See C standard Library Header Files

int main()

main() is a function that is responsible for starting the execution or termination of a program. It is likely the starting point of the execution. basically, it tells the return type of the program. As return data type it has ‘int’ or ‘void’. In the above “hello world” program we have used int as a return data type. You can use ‘void’ as well for the same output.

The keyword void is used when we do not have any value to return to the calling function. Void reference to empty data type or more precisely a data type that has no return value.

The keyword int references to integer data type. when it is used with the main() function that means the function must return integer data (value). In the above program, we have used int with the main() function.

When we use int with main() function then it is compulsory to use return 0; statement at the end. The successful execution of the program is represented by this statement at the end of the main function. any other statement represents unsuccessful termination. In the above program, the value of the return is 0 but if it were 1 that represents the unsuccessful execution.

Read: All HTML5 Tags with their Uses and examples

{ } braces

The curly braces here in C language represent the start and end of a series of statements. In the above program these {} curly braces are representing the series of statements within the main() function.

printf(“hello world”);

printf() is a predefined standard function of the C library. It can be used in any source file by declaring stdio.h header file with the help of preprocessor directive. In the above program as you can see and read printf() function is used to print hello world on the screen.

The syntax is really simple of printf() function. All you need to do is to write the value (data/information) inside the printf() function. Double quotes are used to identify the start and end of the value. At the end, you need to place a semicolon ; which is mandatory for each statement in a C program.

return 0;

As mentioned above the return 0; statement represents the successful execution of the program. the return 0; statement is compulsory whenever int is used with the main() function. We have used int main() in our hello world C program which is why we need this statement. If we use void main() then we do not need this statement.

Read: Programming Language and Its Types

Last words

I hope this article has helped you. Thanks for reading. Stay with us to learn more informative articles.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store