Explain the different sections in C language

C program is defined by set of protocols that are to be followed by a programmer, while writing the code.


The complete program is divided into different sections, which are as follows −

  • Documentation Section − Here, we can give commands about program like author name, creation or modified date. The information written in between/* */ or // is called as comment line. These lines are not considered by the compiler while executing.

  • Link section − In this section, header files that are required to execute the program are included.

  • Definition section − Here, variables are defined and initialised.

  • Global declaration section − In this section, global variables are defined which can be used throughout the program.

  • Function prototype declaration section − This section gives information like return type, parameters, names used inside the function.

  • Main function − The C Program will start compiling from this section. Generally, it has two major sections called as declaration and executable section.

  • User defined section − User can define his own functions and performs particular task as per the user’s requirement.

General form of a ‘C’ program

The general form of a C program is as follows −

/* documentation section */
preprocessor directives
global declaration
main ( ){
   local declaration
   executable statements
returntype function name (argument list){
   local declaration
   executable statements


Following is the C program using function with arguments and without return value to perform addition −

 Live Demo

void main(){
   //Function declaration - (function has void because we are not returning any values for function)//
   void sum(int,int);
   //Declaring actual parameters//
   int a,b;
   //Reading User I/p//
   printf("Enter a,b :");
   //Function calling//
void sum(int a, int b){//Declaring formal parameters
   //Declaring variables//
   int add;
   //Addition operation//
   //Printing O/p//
   printf("Addition of a and b is %d",add);


You will see the following output −

Enter a,b :5,6
Addition of a and b is 11

Updated on: 15-Mar-2021

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started