C Program to Print Hello World

Hello World is the first program to try, if you want to learn any programming language to understand the structure of the code in that language. Here is the code for Hello World written in C.

The Line 1 in the below code shows the comment line. In C, we have Single line comments and multi line comments.
Single line comments in C can be written with double slash, such as //
multi line comments in C can be written as /* ... */

Line number 3 is a header file in C, which contains library files such as formatted input and output functions like printf and scanf.

In C, we can write Void main and int main, from here, the program execution starts.

void main() means, the function doesn’t return any value.

int main() means the main function return an integer value. Normally it returns 0 to OS after successful execution.

/* Program Name: HelloWorld.c */

#include <stdio.h>

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

    return 0;
}

The output of the above code is Hello World!

Leave a Reply

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