What is Structure in C program
Structure of the C program
Q) Draw the structure of the C program. Also, give one example.
Q) Write and explain the structure of a C program.
Almost all programs are written using the following general structure.
Image Source ~ Crafted With ©Ishwaranand – 2020 ~ Image by ©Ishwaranand |
- Document section:
This section consists of a set of comment lines that describe the name of the program, its purpose and other information.
E.g  /*
   This is my first C program
   */
- Link section:
This section contents the instruction for linking the library function with the program. It generally contents #include preprocessor directive.
E.g. # include >studio.h>
- Definition section:
This section is used to define the symbolic constants used in the program. It generally contents#define preprocessor directive.
E.g.
#define PI 3.14
- Global Declaration Section:
This section is used for global variable declare and function declare used in the program.
E.g.
int maximum (int,int);
- main() function section:
Every program must contain the function called main()function. The execution of a program is started from the main() function.
E.g.
 voild main()
{
statements;
}
- Sub-program section:
This section is used to define the user-defined function.
E.g.voild test()
{
….
}
- E.g.
/*Document section (program for addition)*/
# include <stdio.h>Â /* Link section */
void main()Â Â Â Â Â /*main()function*/
{
int a=10, b=5, c;
c = a + b ;
printf(“addition is =%d”, c);
}
Last updated on Sunday - May 21st, 2023