main() function. The following is the C Hello World program that displays a greeting message on the screen.
1
2
3
4
5
6
|
#include <stdio.h>
main()
{
printf("Hello World!\n");
return 0;
}
|
- First, we have the
#includedirective. Every directive in C is denoted by a hash (#) sign. C program uses this directive to load external function library. In the program, we used thestdio.hlibrary that provides standard input/output functions. We used theprintf()function, which is declared in thestdio.hheader file, to display a message on the screen. - Next, you see the
main()function. The main() function is the entry point of every C program. A C program logic starts from the beginning ofmain()function to its end. - Third, you notice that we used the
printf()function that accepts a string as a parameter. Theprintf()function is used to display a string on the screen. Themain()function is supposed to return an integer so we put thereturn 0statement at the end of the program. You can omit thereturnstatement, which is fine.

















