Basic Structure of C program

Basic Structure of C program


Basic Structure of C program

Basic Structure of C program contains the following sections.

  1. Documentation section.
  2. Link section.
  3. Definition section.
  4. Global declaration section.
  5. main () function section.   
  6. Subprogram section.
  7. The user-defined section.

  1. The documentation section consists Of a set of comment lines giving the name of the program the author and other details, which the programmer would like to use later.
  2. The link section provides instructions to the compiler to link functions from the system library.
  3. The definition section defines all symbolic constraints
  4. The global declaration section defines global variables that are used in more than one function and this section also declares all the user-defined functions.
  5. Every C program must have one main () function section. This section contains two parts
  •             Declaration part: The declaration part declares all the variables used in the executable part.
  •             Executable part: There is at least one statement in the executable part.
These two parts must appear between the opening and the closing braces. 
The program execution begins at the opening brace and ends at the closing brace.
The closing brace of the main function section is the logical end of the program
Most of the statements in the declaration and executable parts end with a semicolon.

6. The subprogram section contains all the user-defined functions that are called in the main function.

7. User-defined functions are generally placed immediately after the main function, although they may appear in any order.

NOTE: All sections, except the main function section, maybe absent when they are not required.

structure of c program
structure of c program
Example of the structure of c program

Example of the structure of c program
Example of the structure of c program

Video tutorial:


No comments:

For Query and doubts!

Powered by Blogger.