Structure of a C Program
Figure: Basic Structure Of C Program
Sample Program
The C program below finds the area of a circle using a user-defined function and a global variable PI holding the value of π.
Sections of the Program
1. Documentation Section
The documentation section contains details about the program such as:
-
File name
-
Author name
-
Date of creation
-
Description of the program
It provides an overview for anyone reading the code.
2. Link Section
This section declares the header files used in the program.
It tells the compiler to include system libraries.
3. Definition Section
In this section, constants are defined using the #define directive.
4. Global Declaration Section
This section declares:
-
Global variables
-
User-defined function prototypes
5. Main Function Section
Every C program must have a main function.
It contains:
-
Declaration part → where variables are declared
-
Execution part → where statements are written
Both parts are enclosed within curly braces { }.
6. Subprogram Section
This section contains user-defined functions used in the program.

Comments
Post a Comment