Hello World in C Programming – Learn to Code Easily

Most of the beginners start their programming journey by printing Hello World in C programming or any other programming languages.

In this tutorial, we will do the same, but we will learn each of the line step-by-step. This will not only help you to understand the basic concepts but also helps you to learn in-depth. So, let’s get started with the full code and line-by-line explanation.

The Full Code

#include<stdio.h>
int main()
{
	printf("Hello World!");
	return 0;
}

#include<stdio.h>

I am starting with the ‘#‘ symbol, it tell us that this is a pre-processor. Well, what does that mean?

C compiler starts its execution from the main() function, but before that, it pre-processes the source code. The compiler will process the ‘#’ statement first, and then it will start the execution from the main() function.

Then we have ‘include‘, what do you mean by include, add or insert something, Right? Exactly, so here we are telling the compiler to include the stdio.h file in our program.

The stdio.h file contains all the functions to work with the inputs and outputs. It stands for Standard Input-Output(stdio) [ Please note, this is stdio, not studio ] Header file(.h is the extension for header files). And those two tags ‘< >‘ is specially used for the header files.

So, what does that means all together? It means we are instructing the compiler to include the stdio.h file in our program before main() execution. So that, we can work with inputs and outputs, especially with printf() and scanf().

There is a lot more we can do the pre-processor, we will see that in the upcoming tutorials.

int main()

This is main() function I was talking about. C compiler starts its execution from here. You may have your own defined functions declared at the top of your code, but then also it will start executing the code from main() function.

int main() represents integer main() function and it will return us some value. You must have main() function in your code.

All the statements inside the main() function are enclosed between these two curly braces { }.

printf(“Hello World!”);

Here we are telling the compiler to print Hello World!. So, we are using printf() function from the stdio header file to print the line, and that’s why the #include<stdio.h> was necessary.

printf() means print formatted, which means it obeys some rules, some formats. So, we just can’t write anything within the printf(), we need to know the syntax of format.

Inside the parenthesis ( ) we have to put ” “. Inside the ” “, we can write whatever we want to print. Later, we will learn more about printf() in the upcoming tutorials, where we will learn to print values of variables and many more.

return 0;

We are using the int main() function, which means it will return some integer value. So, we are returning 0, if all the previous statements are true. If the compiler does not find any error before ending the main function, then it will return 0 which means a positive/true result, else it will return a non-zero number. return 0 also represents the end of the main function.

Watch Tutorial

That’s all for this code. Here is so much is going on for printing Hello World in C programming language within some seconds. Subscribe to get updates on Programming, Linux, Machine Learning tutorials, and do follow our YouTube channel.

Sayan De

Sayan De is pursuing his M.Tech in CSE. His interest area of work is Machine Learning, Deep Learning, Deep NLP, Computer Vision, Data Science, Linux, and a little bit of Website Development.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.