Basic Structure of C Program with example explain
C program follows some basic Structure, So we will learn Basic Structure of C Program with example and with proper explanation.
Basic Structure of C Program
The program written in C language follows this basic structure. The sequence of sections should be as they are in the basic structure. A C program should have one or more sections but the sequence of sections is to be followed:
1. Documentation section
2. Linking section
3. Definition section
4. Global declaration section
5. Main function section
6. Sub program or function section
In now let us discuss in detail.
DOCUMENTATION SECTION
DOCUMENTATION SECTION is used to document the use of logic or reasons in your program. It can be used to write the program's objective, developer and logic details.
The documentation is done in C language with /* and */ . Whatever is written between these two are called comments.
LINKING SECTION
e.g. #include
DEFINITION SECTION
GLOBAL DECLARATION SECTION
MAIN FUNCTION SECTION
- Declaration section : In this the variables and their data types are declared.
- Executable section : This has the part of program which actually performs the task we need.
SUB PROGRAM OR FUNCTION SECTION
Example of SIMPLE ‘C’ PROGRAM:
/* simple program in c */
#include <stdio.h>
main()
{
printf(“welcome to c programming”);
}
/* End of main */
Comments
Post a Comment