Basic Structure of C program

There are following structures of a basic C program.

  • Documentation Section

Documentation section consists of a sets of comment lines including name of the program, name of the author and other details.
This section uses comments.
It is written after // if comment is in one line only. Otherwise the section is written inside    /*    */   if the comment line is in one or more lines.

  • Linker Section

Linker Section provides instruction to the compiler to link functions with program from the system library.
It links header files to the program.
It starts with #include and include header files having .h extensions.
For example: 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

  • Definition Section

In this section we can define symbolic constants and macros.

It is also known as macros definition.

It begins with #define

  • Global Variable Section

This section is used to declare global variables and function prototypes.
Global variables are that variables which are used in more than one functions.
A function prototype is a declaration of the function that tells the program about the type of the value returned by the function and the number and type of arguments. 

  • Main() Function Section

The main() function is mandatory in C programming.
This part of programming contains the statements that are to be executed by the compiler.
C program can’t run without a main function.
It has two parts    
1) Declaration part
2) executable parts

  • Subprogram Section

This section consists of all the user defined functions which are called in main function
It is optional section. i.e. C program can run without a subprogram. But it is used to simplify the program and to reduce the effort.


Tutorial video in Nepali language.




Post a Comment

Previous Post Next Post