Monday 19 June 2017

C Program Structure

C Program Structure

The basic C program structure is defined by sett of rules called "Protocol" , to be followed by programmer while writing C program. All C programs are having parts which are mentioned below.

  1. Documentation Section
  2. Link Section
  3. Definition Section
  4. Global declaration Section
  5. Function prototype declaration section
  6. Main function
  7. User defined function definition section


C program to compare all the sections:

/*Ducumentation Section
Authore: CoderBaba  
Date: 19/06/2017*/

#include<stdio.h>   //Link Section
int tot=0;                 //Global declaration & definition section
int sum(int, int);
int main()

printf("C programming\n");
tot=sum (1, 1);
printf("sum of two numbers: %d\n",tot);
return 0;

int sum (int a, int b)                //User defined function
{                                            //definition section 
return a+b ;

C programming
Sum of two numbers :

Description of each section

1. Documentation Section:
                   give comments about the program, creation or modified date, author name etc .
2. Link Section :
                  Header files are included in this section.
3 Definition Section:
                  variables are defined & values are set to these variables.
4  Global Declaration Section :
                       global variable are defined in this section.
5 Function Prototype Declaration Section:
                                   function prototype gives many information about function like return type, parameter names used inside the function and also we declare a function.

6 Main Function: 
                         main function declare here ...
7 User Defined Function:  
                  can defined own functions in this section.

No comments:

Post a Comment

Popular Posts