How to write Hello World in C
Write the program
Save this source as hello.c. The .c extension identifies C source code.
#include <stdio.h>
int main(void)
{
printf("Hello, World!\n");
return 0;
}
Include the declaration
stdio.h declares printf. Include the correct standard header before calling a library function.
Start in main
A hosted C program begins at main. Writing main(void) explicitly says that it accepts no arguments.
Finish successfully
\n starts a new output line. Returning zero reports success to the operating system; reaching the end of main also returns zero in modern C.