Basic Structure of C Program

In this tutorial, we learn about basic structure of c program and also brief descriptions of all sections. The perfect c program is divided into six components. Below we describe the structure of c program in detail and try to give answers to all common questions related to this.

Let us understand the c basic structure with diagram first how the programming structure of c looks like and it set image in the mind of the programmer as we know that if we learn a thing with images easy as compare to the theory and then learn with a brief explanation of all sections. 

Basic structure of c program with block diagram

Below diagram shows all sections in the sequence are:
basic structure of c program
Basic Structure of C Program

Above we see the image which shows all the sections whose combined make a perfect indenting c programming language which shows the clarity of programming structure and it helps you in future if you a beginner when you see other codes or someone see your code then it is easy to understand that where is the global declaration section, definition section, and so on in c programming language because it is global structure and followed by all programmers.   

Structure of c program documentation section 

 * Author: Veer Bhadra

 * File: first.c

 * Description: My First Program

This section contains multi-lines comments description documentation of code which shows about the author, file name, date, description of code and other important pieces of information. 

Link Section 


This is known as include information about the standard library. We link header files to the program that is required. Header files are files with .h extensions. It gives instructions to the compiler to link functions from the system library to the program. Examples: stdio.h, stdlib.h, math.h, string.h, etc.


  #define SIDE 4  

All the symbolic constants are written in the definition section. We use #define (preprocessor compiler directive) to create constantly. 

Global Declaration Section 

int add(int n); 

The global section is used to declare the user define functions declaration. It is also used to declare global variables and both can be used anywhere in the program.

main() function 


   variable declaration
   execution part

main() function is special function in program why main() is special? because main() is the only function which presents in each and every program and the execution of the program from the beginning of main(). main() function excepts no arguments which indicate an empty list.

Each declaration and execution parts are ended with semicolon(;).


int add(int n)
  return SIDE+n;

In this section, we define the functions that are declared in the global section to perform specific tasks or user-defined functions are called from the main() function.

In this above article, We discuss the basic structure of c program and also understand each section with descriptions. If you have any doubts about this then comment below.

Happy Coding😍

Share this

0 Comment to "Basic Structure of C Program"

Post a Comment