Responsive Ads Here

Basic Structure of a C program

All C programs are having sections/parts which are mentioned below  :

  • Documentation Section
  • Link Section
  • Definition Section
  • Global Declaration Section
  • Function Prototype Declaration Section
  • Main Function
  • User Defined Function Definition Section

Basic Structure Program :

/*
     Documentation Section
*/

#include<stdio.h>            //Link Section
int total = 0;                     //Global Declaration
int sum(int, int);              //Function Declaration
int main()                        //Main Function
{
     printf("Basic Program \n");
    total = sum(1,5);
     printf("Sum = %d \n", total);
     return 0;
}
int sum(int a, int b)          //User Defined Function
{
     return a + b;               //Function Definition section
}
     

Output:

Basic Program
Sum = 6