BASIC STRUCTURE OF A 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.
1. Documentation section
2. Linking section
3. Definition section
4. Global declaration section
5. Main function section
{
Declaration section
Executable section
}
6.Sub program or function section
1. DOCUMENTATION SECTION : comes first and is used to document the use of logic or reasons in your program. The documentation is done in C language with /* and */ . Whatever is written between these two are called comments.
2. LINKING SECTION : This section tells the compiler to link the certain occurrences of keywordsor functions in your program to the header files specified in this section.
e.g. #include <stdio.h>
3. DEFINITION SECTION : It is used to declare some constants and assign them some value.
e.g. #define MAX 25
Here #define is a compiler directive which tells the compiler whenever MAX is found in the program replace it with 25.
4. GLOBAL DECLARATION SECTION : Here the variables which are used through out the program
(including main and other functions) are declared so as to make them global.
e.g. int i; (before main())
5. MAIN FUNCTION SECTION : It tells the compiler where to start the execution from
main()
{
point from execution starts
}6. SUB PROGRAM OR FUNCTION SECTION : This has all the sub programs or the
functions which our program needs.
SIMPLE ‘C’ PROGRAM:
/* simple program in c */
#include<stdio.h>
main()
{
printf(“welcome to c programming”);
}/*end of main*/
*