Turn Desktop View Off
You are here:   HomeC Programming (Theory)Basic Of C Prog.Anatomy of C Program
by Dinesh Thakur Category: Basic Of C Programming

The anatomy of a program

We have some compiler preprocessor commands. This includes various #include files. Then comes the main function. Some name can also be given to the main function. Then, we have the variable declarations used in the main code. Then we have sub-functions.


main function name()



variable declaration



sub-function-name (arguments)

argument declarations


variable declarations




In the previous example, we had the sub functions as a separate files. But you can also include them it into the main code. In this case, in one file, we can have main program of the main function and sub-functions or separately. It is a good idea to have the sub-functions separately. We also compile them n link them separately.


It is always safer to do that. For large programs, it is good to have sub functions separately. Sub function has also the same structure like main function. It might have some arguments which would be passed into it. Then comes argument declaration. Then we have some variable declarations which is only private to sub functions only. We will see the examples of these.


Before going to the example, let us look at each one these in detail.


The standard C compiler has four filters. The first one is known as the preprocessor. This part handles the inclusion of files mentioned using the #include command, definition of constants, macro definition etc.

The second filter checks the language statements, generates a symbol table and reports any errors found.

The third part generates the code and a fourth filter optimizes the code for better performance

The fourth one optimizes the function. It improves the code and modifies the code and so that it runs faster. This is an optional part of the compiler.


Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article