“Hello World” Program in C

In this C Programming example, we will implement the very basic and the first of all “hello world” program. We will also discuss different code sections and the meaning of each line of the code.

1. Writing the “Hello World” Program

Let’s implement a very basic example in which we print “Hello World” in 2 different ways.

  • One is directly in the main method
  • Calling a function from the main method that prints “Hello From Function!!!”

Helpful topics to understand this program better

#include <stdio.h>

void hello(){
    printf("\nHello From Function!!!");

int main(){
    printf("Hello World!!");

    printf("\nCoding is fun with Codingeek");
    return 0;
Hello World!!
Hello From Function!!!
Coding is fun with Codingeek

2. Understanding program’s building blocks

Let’s discuss various sections of the program in previous section

  • #include is a preprocessor which is here used to include the contents of file stdio.h. 
  • stdio.h is a file that contains functions like printf(), scanf() etc that helps in performing IO operations.
  • int main() is the main function which contains the set of statements to be executed. This is the entry point for the program.
    No matter whether this function is written in the beginning or end, execution will always start from main().
  • void hello(){ } declares a function and contains the code that should be executed once it is called.
  • printf() is a library function that sends the formatted output to the screen.
    \n is used wherever we want a line break or want the output to start from the next line.
  • hello(); statement calls the already declared function. This is similar to printf() which is also a function and we call it to perform some task.
  • The return 0; statement is the “Exit status” of the program. The value 0 means the program has executed without any error.

3. Conclusion

In this C Programming example series, we have discussed the first program in C i.e. How to print Hello World in console, a very quick basic look at the functions, and also discussed the meaning of all the different statements used to write this basic program.

Helpful Links

Please follow C Programming tutorials or the menu in the sidebar for the complete tutorial series.

Also for the example C programs please refer to C Programming Examples.

All examples are hosted on Github.

An investment in knowledge always pays the best interest. I hope you like the tutorial. Do come back for more because learning paves way for a better understanding

Do not forget to share and Subscribe.

Happy coding!! šŸ˜Š

Recommended -

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x