C Programs generally follow a set structure which has six different sections.

  1. Documentation section
  2. Link section
  3. Definition section
  4. Global declaration section
  5. Main function section
  6. Subprogram structure

Let’s understand them one by one.

  1. Documentation Section – It contains the information about the program, but it is not compiled by the compiler.
  2. Header or Link Section – This includes all the important library functions for the program to be executed.
  3. Definition Section – It defines all symbolic constants.
  4. Global Declaration Section –Variables used in more than one function are known as Global variables and are defined in the global declaration section.
  5. Main Section – Every C program must have one main function. Two parts of this section are

  1. Declaration Section – Variables used in executable parts are declared in this section.
  2. Executable Section – There should be one statement in the execution section.

Declaration Section and Executable section begins with opening braces ( { ) and ends at closing braces ( } ).

All the statement in both these sections ends with a semicolon (;).

6. Sub-program Section – It contains all user-defined functions which are called in the main function. User-defined functions can appear in any order but generally, they are placed immediately after the main function.

Let us now see an example code to find the area of circle.

/*Program to find the area of the circle */
float rad, area;
printf("Enter the Radius = ");
printf("Area of circle is %f",area);

Leave a Reply

Your email address will not be published.