Basic Structure of a C program contains following sections,

 Documentation Section

Link Section

Definition Section

Global Declaration Section

main()

{

Declaration Section

Executable part

}

Subprogram section

Function 1

Function 2

.

.

function n

 

The Documentation Section consists of a set of comment lines giving the name of the program and other details.

The Link Section provides instructions to the compiler to link functions from the system library. C program depends upon some header files for function definition that are used in the program. Each header file has extension ‘.h’. The header files are included at the beginning of the program in the C language. These files should be included using #include directive as given below

Example:

#include

(This will find header file in standard directory)

or

#include “stdio.h” ( This will find header file in Current and Standard directory)

-The Definition Section defines all symbolic constants.

The Global Declaration Section: There are some variables and those variables are declared in this section that is outside of all functions.

main() function: Every C program must have one main() function section. int main(void): This is the function definition for main().Parenthesis followed to main is to tell the user again that main() is a function. int main(void) function return an integer.

void main(void): This function takes no arguments and return nothing.

void main(): This function returns nothing and takes no arguments. The program contains statements that are enclosed within the braces. The opening braces “{“ and closing braces “}”.

In these two braces main() function contains two parts,

declaration and executable part. It is user defined function. The Opening braces sometimes called logical start and Closing braces known as logical end of the program.

Declaration Part declares all the variables used in the executable part. There should be at least one statement in the executable part which contains instructions to perform certain task. The declaration and executable part must appear between the opening and closing braces. All statements in the declaration part should end with the semicolon.

The Subprogram Section contains all the user defined functions that are called in the main function.