C program basically consists of the following parts:−
- preprocessor directives Section
- Definition section
- Main Function Section
- Variables Section
- Comments Section
- Sub Program Section
preprocessor directives Section:- This part of the code is used to declare all the header files that will be used in the program. The first line of the program #include <stdio.h> is a preprocessor command. It provides instruction to the compiler to link the header files or functions from the system library.
Definition section:- We define different constants. The keyword #define is used in this part.
i.e:- #define PI=3.14
Main Function Section:- Every C-programs needs to have the main function. Int main() is the main function where the program execution begins. This section contains two parts: Declaration part and Executable part.
Variables Section:- There are two types of variable.
- Local variable- Variables that are declared inside the main function.
- Global variable- Variables that are declared outside the main function. There are some variables that are used in more than one function, such variables are called global variables.
Comments Section:- Coding description is called comments. We write comments provide information and better understanding of the program or about lines of code.
// or /* */ used for comments in C programming.
Sub Program Section:- It contains all user-defined functions that are called in the main() function.