# Explain the different sections in C language

CServer Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

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

## Sections

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
}

## Example

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

Live Demo

#include<stdio.h>
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;
printf("Enter a,b :");
scanf("%d,%d",&a,&b);
//Function calling//
sum(a,b);
}
void sum(int a, int b){//Declaring formal parameters
//Declaring variables//
}
Enter a,b :5,6
Addition of a and b is 11