C

9 Simple Sections of Basic Structure of C Program

Basic Structure of C Program
Arjan Solanki
Written by Arjan

Basic Structure of C Program

Basic Structure of C Program: All the programs used before the development of this language were made in the Assembly language. Programs created in the Assembly language are much higher, but there is also a lack of it.

The program developed in Assembly language is Execute on the same computer, which it has been developed. That’s why a programming language needed, which is portable.

Based on this need, in the year 1960, Cambridge University developed a computer programming language, named “BASIC Combined Programming Language”, which means BCPL.

In 1970, Ken Thompson made some changes, and in general it was named “B” language. “C” was developed in the United States in 1972. Dennis Ritchie, the computer scientist at AT & T Laboratory, developed this.

“C” is a powerful language, in which we can make software both application software and system software. Programs are created through normal English words, which are easy to understand and make. That is, in a certain order of information the program runs.

Characteristics of “C”

“C” is quite simple from many other languages. “C” is a very flexible language compared to other high level languages. “C” is a language that can also be used with computer hardware and memory management can also be done.

The biggest feature is “C” portability.

That is, programs written in “C” language can run in any other computer environment.

“C” is a high level Structured Programming Language or Functional Programming Language, meaning that all work is done by using different types of Functions, Procedures, or Structures.

“C” has no input output operation. The “C” compiler does all the work of input-output through the Library function.

Block Structure of “C” Programs

  • Documentation Section
  • Link Section
  • Definition Section
  • Global Declaration Section
  • Main() Function Section
  • {
    • Declaration Part
    • Executable Part
  • }
  • Sub Program Section
    • Function 1
    • Function 2
    • . . .
    • Function n

Layout Structure of “C” Programs

  1. /* Comment about the Program */
  2. Including The Header Files
  3. Global Variables Declaration
  4. Main()
  5. {
  6. Local Variables Declaration
  7. Necessary Statements
  8. }
  9. Sub Program Functions
    Function 1
    Function 2
    :
    Function n

Documentation section

In this part of the program, we write some points related to the program as a comment, so that the program is created for what reason and what is the feature of the program. This documentation is very useful for understanding and maintaining the flow of the program.

Link section

Here we declare the header files of the “C” program, which are required in our program. Since C language is a Functional Programming Language, we have to use different types of Library Functions to meet different types of needs and these Library Functions are provided as Header Files as well as C Compiler. To get used to our program, the related Header File is specified in the link section of the C Program with the “#include” Statement.

Definition section

Here user Defined Data Types are define, which we define ourselves according to our needs. Here we also define our own User Defined Functions or define their prototype.

Global Declaration Section

Constants defined here are commonly defined with the “#define” Statement, which are also called Global constants, because these constants can be used anytime and anywhere during the entire program. Just like the Global Constants we declare them in this section, the variables that we have to use in a global way throughout the program.

main () Function Section

This function is in every “C” program. While compiling, Program Control uses the main function first and starts the execution of this function. There is only one main function in every “C” program, and it is necessary to have the main() function in every “C” program, because the Execution of the program starts with the main function.

Opening Parenthesis ({)

After getting the main() function, the execution of the program starts with this median bracket. That is, Opening Parenthesis only represents the introduction of any User Defined Function.

Declaration Part

All the variables, constants, arrays, etc. that are used in the program have to be disclosed here. For those of us who declare here, “C” program makes room in memory at the time of execution, which is later used as per their requirement.

The variables and constants that we declare here are only useful and accessible for the Current Function. These identifiers can not be accessed outside the body of the Function i.e. Opening and Closing Curly Braces, because the body of the Function is the scope of these identifiers, and with the Closing Parenthesis of the Function, the life time or visibility of these Identifiers ends.

Executable Part

Here are all the statements of the program, through which we want to get results from the program. This is the part from which the work of Interface for the user starts. Normally, from the Declaration Part of the Function, the Function’s Closing Curly Brace is known as the Executable Part.

Closing Parenthesis (})

In the program, there is the use of the second median bracket where the program or the Function has to end.

Sub-section section

Function 1;
Function 2;


Function n;

There are user define functions in this part of the program. In a main () program, the main function is the same, but according to the User Defined Function requirement, there may be many. These are Functions that are not Exist in any Header File, but the Programmer defines them according to their own needs and these functions are limited to the Scope of the Current Program only. If these Functions are to be used in any other application program, either they have to copy-paste or after embedding them as a Header File, by inserting that Header File into a new application, In User Defined Functions Can be used again.

Thus, any C program basically has 9 parts, although not all parts are required to be specified in all the programs. However, having a link section, main () Function, Opening and Closing Parenthesis and Executable Part in any C program is compulsory for a complete and running C program.

I sincerely hope that I have given you full information about Basic Structure of C Program and I hope you have understood about Basic Structure of C Program. I am convinced of all the readers that you too share this information with your neighbors, relatives, your friends, so that we will be aware of our interactions and will all benefit from it. I need people’s support from you so that I can bring you even more new information.

My always try is to do that I always help my readers or readers on every side, if you have any doubt of any kind, then you can ask me uncomfortable. I will definitely try to solve those Doubts. Please tell us what you think of this article, so that we can get a chance to learn something from your thoughts and improve some.

Get new posts by email
Please follow and like us:
0

About the author

Arjan Solanki

Arjan

To seek the challenging position in Development environment that needs Innovation, creativity, dedication and enable me to continue to work in a challenging and fast paced environment, leveraging my current knowledge and fostering creativity with many learning opportunities.

4 Comments