Summary: in this tutorial, you will learn step-by-step how to develop the first simple but famous program called C Hello World.
A C program consists of functions. A C program always starts executing in a special function called
main() function. The following is the C Hello World program that displays a greeting message on the screen.
Let’s examine the program in more detail.
- First, we have the
#includedirective. Every directive in C is denoted by a hash (
#) sign. C program uses this directive to load external function library. In the program, we used the
stdio.hlibrary that provides standard input/output functions. We used the
printf()function, which is declared in the
stdio.hheader file, to display a message on the screen.
- Next, you see the
main()function. The main() function is the entry point of every C program. A C program logic starts from the beginning of
main()function to its end.
- Third, you notice that we used the
printf()function that accepts a string as a parameter. The
printf()function is used to display a string on the screen. The
main()function is supposed to return an integer so we put the
return 0statement at the end of the program. You can omit the
returnstatement, which is fine.
Developing C Hello World program in CodeBlocks IDE
In the following section, we will show you step-by-step running the C Hello World using CodeBlock IDE. If you don’t have any C IDE installed in your system, you can setup CodeBlocks IDEB by following the setting up C development environment tutorial.
Launch the IDE, and create a project from the menu File > New > Project…
Congratulation! You have been successfully developing and running the first C Hello World program. Let’s go to the next tutorial to explore the power of C programming language. Enjoy programming with C!