“Hello World..!” program in C

Hey there!!

Welcome to ClearUrDoubt.com.

In this post, we will look at the basic C program to print “Hello World” message to the console. If you are working on a Windows machine, you can use Dev-C++ to write and execute C programs.

Here is the C program:

Let’s go through each line and explore the details.

This statement will include a file called “stdio.h” in your code. “stdio” means Standard Input/Output. So all the predefined/inbuilt functions related to Standard IO are defined in “stdio.h” header file.

 

main is the function where the execution starts. the above statement tells the compiler that this function is going to return an integer to the operating system once the program is completed.

 

these curly brackets are used to group all the statements in this function.

 

“printf()” is an inbuilt function defined in “stdio.h” which will output the message passed as a parameter to it. In the above statement, “\n” tells the compiler to add a new line character(called “escape sequence” in C) in between the statements so that it will print the two sentences in two lines.

 

Finally, this statement returns the value “0” to the operating system and the execution stops.

 

Below is the output generated once the program is executed:

 

 

 

 

 

Also, C language supports “comments” in the programs so that they can be made readable. There are two types of comments 1) Single Line comments and 2) Multi-Line comments.

Single Line comments are given using “//” and Multi-line comments are included in between “/*” & “*/”.

Congratulations on learning the first program in C :). Please leave a reply in case of any queries.

 

Leave a Reply

Your email address will not be published.