Program:
#include <stdio.h> int main() { printf("Hello World!"); return 0; }
Know it:
- #include <stdio.h> is a pre-processor directive. When the above program is compiled the compiler replaces the first line with entire contents of stdio.h file. The stdio.h (Standard Input/Output) is called as header file and contains functions for basic input/output operations.
- int main() is a function and defines the starting point of our program. It contains two parts:
int It is the return type of the function. It specifies that the main() function should return an integer value when its work is finished.
main() It is an identifier or name of the function.
Note: The starting point of any program in C is defined by main function. - The next line contains pair of curly braces. In C we use a pair of curly braces to define a block of statements. An opening curly brace is always followed by a closing curly brace.
- printf(); is a function used to print any data on screen. Anything inside the double quotes " " will be printed as it is on screen.
- return 0; returns an integer value to the operating system or the Runtime environment of C acknowledging OS/C Runtime Environment that the program has terminated successfully.
If you have written the above program same as in the source code without making any mistake then it should print Hello World! on the screen.
View next C tutorial Declaring variables in C.