Note: Serial numbers are not included in the syntax of the program.
-------------------------------
1. #include <stdio.h>
2. void main()
3. {
4. printf("Hello World!");
-------------------------------
1. #include <stdio.h>
2. void main()
3. {
4. printf("Hello World!");
5. }
Explanation:
In first line "#" sign indicates the starting of preprocessor directive. The instructions after the # sign are for the compiler and not for the processor that's why its called preprocessor directive. The instructions after the # signs tells the compiler to include the header file stdio.h. Stdio.h is a header file which contains prototypes/declarations of different input output functions e.g. printf() , scanf() etc.
The next line starts the main function. The main() function is the core of every program. All C language programs must have main() function. When the program executes the controller comes to the main() function and start executing its statements.
The starting and ending curly braces after the main() function is called its body. Now the printf() is in the body of the main() function. printf() is an output function. It's prototype/declaration resides in the header file stdio.h. You cannot use this function if you didn't include the stdio.h file in the program.
---------------------------------
Output:
In first line "#" sign indicates the starting of preprocessor directive. The instructions after the # sign are for the compiler and not for the processor that's why its called preprocessor directive. The instructions after the # signs tells the compiler to include the header file stdio.h. Stdio.h is a header file which contains prototypes/declarations of different input output functions e.g. printf() , scanf() etc.
The next line starts the main function. The main() function is the core of every program. All C language programs must have main() function. When the program executes the controller comes to the main() function and start executing its statements.
The starting and ending curly braces after the main() function is called its body. Now the printf() is in the body of the main() function. printf() is an output function. It's prototype/declaration resides in the header file stdio.h. You cannot use this function if you didn't include the stdio.h file in the program.
