Following is the basic code to understand the structure of a C program.
The Different parts of C program.
All the following parts are essential parts to write a C language program.
1) Pre-processor
The #include which is the first word of any C program is also known as pre-processor.
The main work of a pre-processor is to initialize the complete environment of a program i.e to link a program with the header file ‘<stdio.h>’.
2) Header file
The Header file is a collection of the built in functions that helps us in our program.
The Header file contains the definitions of functions and the variables which can be incorporated into the any C program by pre-processor ( #include ) statement.
The Standard header files are provided with each and every compiler and covers a range of areas like the string handling, all mathematical functions, data conversion, printing and reading of the variables.
To use any of standard the functions, an appropriate header file should be included and this is done at the beginning of the C program or source file.
For example- the use of a printf() function in a program the line #include <stdio.h> is responsible.
3) main() function
The main() function is a function that must be used in an every C program.
Where A function is a sequence of statement which required to perform a specific task.
The main() function starts the execution of a C program that is In the above example , int in front of the main() function is return type of main() function.
The curly braces { } just after main() function encloses the body of main() function.
4) Comment
The Comments are used to just explain the flow or procedure or working of the source code of a C program where the using of Comment is optional.