Structure and Different Sections in C Programming

A C program can be divided into several sections to have a better understanding about the different parts of a C program.

Sections of C Program

Documentation Section
Link Section
Definition Section
Global Declaration Section
main() Function Section
Subprogram Section

Documentation Section

The documentation section contains a set of comment including the name of the program other necessary details. Comments are ignored by compiler and are used to provide documentation to people who reads that code. Comments are be giving in C programming in two different ways:

  1. Single Line Comment
  2. Multi Line Comment
// This is single line comment

This is 
multi line

Link Section

The link section consists of header files while contains function prototype of Standard Library functions which can be used in program. Header file also consists of macro declaration. Example:

#include <stdio.h>

In the above code, stdio.h is a header file which is included using the preprocessing directive #include. Learn more about header files in C programming.

Definition Section

The definition section defines all symbolic constants. A symbolic constant is a constant value given to a name which can't be changed in program. Example:

#define PI 3.14

In above code, the PI is a constant whole value is 3.14

Global Declaration

In global declaration section, global variables and user defined functions are declared.

main() Function Section

The main () function section is the most important section of any C program. The compiler start executing C program from main() function. The main() function is mandatory in C programming. It has two parts:
Declaration Part - All the variables that are later used in the executable part are declared in this part.
Executable Part - This part contains the statements that are to be executed by the compiler.

    ... .. ...
    ... .. ...

Subprogram Section

The subprogram section contains all the user defined functions. A complete and fully functions C program can be written without use of user-defined function in C programming but the code maybe be redundant and inefficient if user-defined functions are not used for complex programs.

Note: Except for the main () function section, other sections of the C program may be omitted as per the requirement of the program.

Basic C Program to Print Hello World

// This is the very simple C program to print Hello Word
// This section is documentation section

#include  // Here stdio.h is header file and this section is link section

int main() {     // main()
   printf("Hello world");
   return 0;


Hello world

The above program, stdio.h header file is included. The function printf() can't be used without the use of stdio.h header file in C program.