Hello World - C program

By  ShC    22 - 04 January, 23
Hello world C program

Share article on social media


"Hello, World" is a simple program that is often used to introduce new programmers to a programming language. It involves writing a program that outputs the text "Hello, World!" to the screen. Here is an example of how to write a Hello World program in the C programming language:

Hello World program in the C programming


#include

int main(void)

{

  printf("Hello, World!\n");

  return 0;

}


Hello World C program

This program consists of a single function, called main, which is where execution of the program begins. The main function is declared with the int data type, which indicates that it will return an integer value when it finishes executing.

The first line of the program, #include , is a preprocessor directive that tells the compiler to include the contents of the standard input/output header file in the program. This header file contains definitions and prototypes for functions that are used to perform input and output operations in C, such as printf, which is used to output a string of characters to the screen.

The next line, int main(void), is the function definition for the main function. The keyword void in parentheses indicates that the function does not take any arguments.

Inside the body of the main function, we have a single statement: printf("Hello, World!\n"). This statement calls the printf function, which outputs a string of characters to the screen. The string "Hello, World!\n" is passed as an argument to the function, and the special character '\n' at the end of the string represents a new line, which causes the text to be output on a new line.

Finally, the main function returns the value 0, which indicates that the program has executed successfully.

When you run this program, it will output the text "Hello, World!" to the screen, followed by a newline. This simple program is a good starting point for learning the C programming language, and it can be modified and extended to do more complex tasks.