Basic Structure of ‘C’ Program | What is the Basic Structure of C Program?

 

Every C program is basically a group of different section that is used for different purpose. The structure gives us a basic idea of the order of the sections in a program. A well-defined structured layout makes program more readable, easy to modify, consistent format and gives better clarity and the concept of a program. Whenever we write a program in ‘C’ language, we can divide that program into six different sections. These sections are as follows:

  • Documentation section
  • Linkage section
  • User definition section
  • Global declaration section
  • Main() function section
  • Subprogram section

 

Pictorial Representation of Basic Structure of C Programming:

 


Figure: Basic Structure of C Program

A program in ‘C’ may not contain all the sections shown above but main() function is a must as the program execution always starts with main() . 

Brief explanation of each section is given below:

Documentation Section:

Documentation section is generally description of program. It is only a set of comments for program documentation. Documentation section consist program’s name, objective of the program, author’s name and other useful details like the creation date, title etc that can be referenced later. It provides an overview of the program.

 Example

/*

Author: Eliza Begum

Date: 2/2/2022

Description: This program calculate simple interest

*/

 

Linkage Section: 

The linkage section consists of the header files that are used in the program. It provides instruction to the compiler to link function from the system library. If the programmer wants any one of the functions, from any one of the header files, there should be a mechanism to inform the compiler. From the link section, we instruct the compiler to link those header files from the system libraries, which we have declared in the link section in our program.

 Example:

#include<stdio.h>

#include<conio.h>

#include<string.h>

 

User Definition Section:

This section is used to define symbolic constants. Symbolic constants are used for better understanding of certain names that are not going to change throughout the program. Generally capital letter is used to define symbolic constants. The keyword define is used in this part. Macros are used in this section.

 Example:

#define PI 3.1415

#define MAX 5

Here, PI, MAX are symbolic constants.

 

Global Declaration Section: 

The global variables that can be used anywhere in the program are declared in global declaration section. Global variables can be used by all the functions. The user-defined functions are also declared in this part. The user defined functions specified the functions specified as per the requirements of the user.

 Example:

int sum(int x,int y);

int a;

float b;

 

Main() Function Section: 

The main() function has control over the program. Every C program must have a main function which is the starting point of the program execution. It contains 2 parts, namely, local variable declaration part and Executable statement part and these two parts must be written in between opening and closing braces. Local variable declaration part is used for declaring local variables which are to be used in executable statement part. Executable statement contains all the instructions to be executed.

int main()

{

int a=5;   // Declaration Part

printf(“a=%d”,a);    /*Execution Part */

return 0;

}

 

Sub Program Section: 

The subprogram section contains all the user defined functions that are used to perform a specific task. All the function subprograms are user defined with an optional list of arguments enclosed in parentheses and generally placed after the main() definition is over. There can be placed in any order.

int sum(int a, int b)

{

return a+b;

}

 

 

58 thoughts on “Basic Structure of ‘C’ Program | What is the Basic Structure of C Program?”

  1. Someone essentially help to make seriously posts I would state. This is the very first time I frequented your website page and thus far? I amazed with the research you made to create this particular publish amazing. Fantastic job!

    Reply
  2. Normally I don’t read article on blogs, but I wish to say that this write-up very pressured me to check out and do it! Your writing taste has been surprised me. Thank you, very nice post.

    Reply
  3. An impressive share, I simply given this onto a colleague who was doing a little bit evaluation on this. And he in reality bought me breakfast because I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to debate this, I really feel strongly about it and love studying extra on this topic. If attainable, as you develop into experience, would you thoughts updating your blog with more details? It is highly useful for me. Huge thumb up for this weblog post!

    Reply
  4. I’m really inspired along with your writing skills as well as with the format to your weblog. Is that this a paid subject or did you customize it your self? Either way stay up the excellent high quality writing, it’s rare to peer a nice weblog like this one nowadays..

    Reply
  5. Hello very nice blog!! Guy .. Excellent .. Amazing .. I’ll bookmark your web site and take the feeds also?KI am glad to search out so many helpful information here in the put up, we want work out more strategies in this regard, thank you for sharing. . . . . .

    Reply
  6. I just could not depart your website before suggesting that I really enjoyed the usual info an individual supply on your visitors? Is gonna be back often in order to investigate cross-check new posts.

    Reply
  7. I’ve been surfing online greater than 3 hours lately, but I by no means found any attention-grabbing article like yours. It’s beautiful price sufficient for me. Personally, if all web owners and bloggers made just right content as you did, the web shall be a lot more helpful than ever before.

    Reply
  8. Fantastic items from you, man. I have have in mind your stuff prior to and you’re just extremely great. I really like what you’ve received right here, really like what you are saying and the way in which wherein you say it. You make it enjoyable and you continue to care for to keep it smart. I cant wait to read far more from you. This is really a terrific site.

    Reply
  9. I?¦ve been exploring for a little for any high quality articles or weblog posts on this sort of area . Exploring in Yahoo I eventually stumbled upon this web site. Studying this information So i?¦m happy to show that I’ve an incredibly excellent uncanny feeling I found out just what I needed. I most definitely will make sure to do not put out of your mind this site and give it a glance regularly.

    Reply
  10. I have been exploring for a bit for any high quality articles or blog posts on this sort of area . Exploring in Yahoo I at last stumbled upon this web site. Reading this info So i’m happy to convey that I’ve an incredibly good uncanny feeling I discovered just what I needed. I most certainly will make certain to do not forget this site and give it a glance regularly.

    Reply
  11. Virtually all of the things you point out is supprisingly appropriate and it makes me wonder why I had not looked at this in this light previously. This particular piece truly did turn the light on for me personally as far as this subject goes. However there is actually one factor I am not too comfy with and whilst I make an effort to reconcile that with the actual core theme of the point, allow me see just what the rest of your subscribers have to point out.Nicely done.

    Reply
  12. Thanks for sharing superb informations. Your website is very cool. I am impressed by the details that you have on this site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found simply the info I already searched everywhere and simply could not come across. What an ideal web-site.

    Reply
  13. I’m impressed, I need to say. Actually rarely do I encounter a weblog that’s each educative and entertaining, and let me let you know, you could have hit the nail on the head. Your thought is excellent; the issue is one thing that not sufficient persons are talking intelligently about. I am very blissful that I stumbled across this in my search for one thing regarding this.

    Reply
  14. Hiya, I am really glad I’ve found this info. Nowadays bloggers publish only about gossips and web and this is actually annoying. A good web site with exciting content, this is what I need. Thank you for keeping this web-site, I’ll be visiting it. Do you do newsletters? Can not find it.

    Reply
  15. I am really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it is rare to see a great blog like this one nowadays..

    Reply

Leave a Comment