Say hello

It is customary to write a small program first, before making larger programs. A small program, with its only task being the display of a text message, saying "Hello, world", is often used. Such a program can be referred to as a Hello world program.

A Hello world program written in C often starts with an include directive. The include directive starts with the word #include, which is an instruction to the C preprocessor. The include directive tells the preprocessor to insert the contents of a file, in this case a file named stdio.h, and it is written as

#include <stdio.h>

The purpose of the include directive is to allow the program to have access to certain functions. A function can be thought of as an aggregation of instructions, put together for a specific purpose. In this program a function named printf is used. This function, which is used in the program as

    printf("Hello, world\n"); 

makes the string Hello, world appear on the screen of the computer where the program is run. The complete program is shown in Figure 1.

#include <stdio.h>

int main(void)
    printf("Hello, world\n"); 
    return 0; 

Figure 1. A hello world program in C.

This the C view - other views are Java - Python

The program in Figure 1 contains a function named main. The purpose of this function is to define a starting point, so that the operating system knows where to start the program when it is executed.

The program ends with a return statment, which returns the value 0 to the operating system, which in your case most likely means Windows, Linux, or some type of MacOS.