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;

}

 

 

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

  1. What i do not realize is in reality how you are no longer actually a lot more smartly-preferred than you might be now. You are very intelligent. You know thus considerably with regards to this subject, produced me individually consider it from a lot of varied angles. Its like men and women aren’t involved except it’s one thing to do with Girl gaga! Your personal stuffs nice. Always care for it up!

    Reply
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. A lot of whatever you mention happens to be astonishingly precise and it makes me ponder the reason why I had not looked at this with this light previously. This particular article truly did switch the light on for me as far as this particular issue goes. But there is one particular issue I am not necessarily too comfortable with and whilst I make an effort to reconcile that with the actual core idea of your point, permit me observe exactly what all the rest of the readers have to point out.Well done.

    Reply
  14. 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
  15. Simply wish to say your article is as astounding. The clearness in your post is just great and i can assume you are an expert on this subject. Fine with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please keep up the rewarding work.

    Reply
  16. 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
  17. 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
  18. 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
  19. I have been browsing online greater than three hours today, but I never found any interesting article like yours. It’s pretty value sufficient for me. Personally, if all site owners and bloggers made excellent content material as you did, the internet might be much more helpful than ever before. “Now I see the secret of the making of the best persons.” by Walt Whitman.

    Reply
  20. Appreciating the dedication you put into your website and detailed information you present. It’s good to come across a blog every once in a while that isn’t the same unwanted rehashed information. Fantastic read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

    Reply
  21. I?¦ve learn a few good stuff here. Definitely price bookmarking for revisiting. I surprise how much attempt you put to make this kind of excellent informative website.

    Reply
  22. Fantastic items from you, man. I’ve take into accout your stuff previous to and you’re just too great. I actually like what you’ve obtained right here, really like what you are saying and the best way during which you assert it. You make it entertaining and you continue to take care of to keep it sensible. I can’t wait to learn much more from you. This is really a great site.

    Reply
  23. Excellent post. I was checking constantly this blog and I am impressed! Extremely useful information particularly the last part 🙂 I care for such information much. I was seeking this certain information for a long time. Thank you and best of luck.

    Reply
  24. Very interesting info !Perfect just what I was looking for! “If you bungle raising your children, I don’t think whatever else you do matters.” by Jacqueline Lee Bouvier Kennedy Onassis.

    Reply
  25. Great post. I was checking constantly this blog and I am impressed! Very useful information specifically the last part 🙂 I care for such information much. I was looking for this particular info for a very long time. Thank you and best of luck.

    Reply
  26. I have not checked in here for a while as I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend 🙂

    Reply
  27. Thank you for some other excellent post. Where else could anybody get that kind of information in such an ideal means of writing? I have a presentation subsequent week, and I am at the look for such info.

    Reply
  28. you’re really a good webmaster. The web site loading speed is incredible. It seems that you’re doing any unique trick. Moreover, The contents are masterpiece. you’ve done a fantastic job on this topic!

    Reply
  29. I simply could not depart your website prior to suggesting that I really loved the usual info an individual provide to your visitors? Is going to be again frequently to inspect new posts.

    Reply
  30. We are a group of volunteers and starting a new scheme in our community. Your site provided us with useful info to work on. You’ve performed a formidable process and our whole neighborhood will be grateful to you.

    Reply
  31. I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

    Reply
  32. I just could not go away your website before suggesting that I actually loved the usual information an individual supply to your visitors? Is gonna be again often in order to check out new posts

    Reply
  33. We’re a group of volunteers and opening a new scheme in our community. Your website provided us with valuable info to work on. You’ve done a formidable job and our whole community will be thankful to you.

    Reply
  34. I’ve been surfing on-line greater than 3 hours today, but I by no means discovered any attention-grabbing article like yours. It¦s pretty worth enough for me. Personally, if all web owners and bloggers made good content material as you did, the net might be much more useful than ever before.

    Reply
  35. Hello there, I discovered your blog by means of Google at the same time as looking for a similar topic, your website got here up, it looks great. I’ve bookmarked it in my google bookmarks.

    Reply
  36. I think other website proprietors should take this website as an model, very clean and excellent user genial style and design, let alone the content. You are an expert in this topic!

    Reply
  37. I have been absent for some time, but now I remember why I used to love this website. Thanks, I will try and check back more frequently. How frequently you update your web site?

    Reply
  38. Admiring the hard work you put into your blog and detailed information you present. It’s great to come across a blog every once in a while that isn’t the same old rehashed material. Excellent read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

    Reply
  39. I used to be more than happy to seek out this internet-site.I needed to thanks for your time for this wonderful read!! I undoubtedly enjoying each little little bit of it and I’ve you bookmarked to check out new stuff you weblog post.

    Reply
  40. Magnificent goods from you, man. I’ve understand your stuff previous to and you’re just too great. I actually like what you’ve acquired here, certainly like what you’re stating and the way in which you say it. You make it enjoyable and you still care for to keep it wise. I can’t wait to read much more from you. This is actually a wonderful website.

    Reply

Leave a Comment