Structure of C program
May 5, 2020Before starting to write a C program, we have to follow some structure.
Let's see the following hello world program to understand the Structure of the C program.
/* this is documentation section */
#include <stdio.h>
#define NUMBER 10
void showGlobal();
int number = 15;
int main(){
printf("hello world\n");
showGlobal();
return 0;
}
void showGlobal(){
printf("Global variable=%d", number);
}
The figure below compares the above program with structure.

1.Documentation Section
The documentation section contains a set of comment lines giving the name of the program, author, and other detail, which the programmer use to give information about the program.
2.Link Section
This section provides the instruction to link the current file with the library or external files. the preprocessor directive "#include <stdio.h>" links the functions and features available in stdio.h library with the current file.
3.Definition Section
In this section, all the symbolic constants are defined. For example, #define NUMBER 10
4.Global Declaration Section
The variables that needs to be known or accessible to all the part or functions of the program are declared global. In this section all the global variables are declared. Also, all the user-defined functions are declared.
5.Main function Section
This is the main section of the program, that the program code actually starts from this function to execute(entry point of the program). This section consists of two parts declaration part and executable part.
•Declaration part
In this section, all the variables that are used in executable part in the program are declared.
•Executable part
This section, consists all the statements that actually do something in the program.
6.Sub Program Section
This section, contains all the user-defined functions that are used in the main program.