CodeNewbie Community

Cover image for Hello World Program in C

Hello World Program in C

alimammiya profile image Alimam Miya ・3 min read

In this tutorial, we will see how to write a hello world program in c, how to write the comments in c program, and what header files are. so let us start.

How can we write a hello world program in c?

To write a program in c we first have to declare the header file. And after that, we have to declare the main function. Inside the main function, we can write the code that we want to execute.

/* Header file declaration */

/* Main function declaration */
int main() {


/* Printing message to screen */
    printf("Hello World!");


/* returning */
    return 0;


Hello World!

In the first-line we will include the <stdio.h> header file in the program. The stdio.h stands for standard input/output .header file. It handles the input and output statements of the program.

After this, the main() function is started. In this function instruction of the program is written. In the Main function, the starting point or endpoint is represented by the curly brackets({ }).

In this, the main function is defined by the int type. The main function has to always return an integer value (int). In the program, if we do not return any value from the main() function then we have to write return 0 at the end of the program.

How to write a comment in the c program?

A comment is a text that is not compiled by the compiler but it is ignored. This text is not executed. Comments are used in the C program to define any statement. A comment is the explanation of the source code of the program. The comments are not executed and are not shown in the executed code.

There are two types of comments- end-of-line comment and block comment. The end-of-line comment terminates at the end of the line. A block line comment contains a terminator and can continue for several lines.

/* This is my first program */

In the C language to define the comments, we use forward-slash (/) along with the asterisk sign (*). It is mainly used by the coder in the longer codes to remind him which part of the code is for what. So that the modification in the code can be done easily. It can also be used as a helper for those who will read the code later. They will be able to understand the code more easily and can change the code according to the requirement.

What is a header file?

The header file is a file that contains function declarations and macro functions. The header file is used for defining all the functions, variables, and constants. When a header file is included in the program by using #include<filename.h>command all the headers are included in the program. The c program is compiled with the help of the compiler and executed. The header file stdio.h includes two standard input-output functions scanf and printf. They contain the function prototype.

Discussion (0)

Editor guide