C - Program Structure
C Program Structure
- C - programming is the structure oriented Programming language in which the programs are compiled and run in a top down approach.
Basic Structure of C- Programming :
1. Documentation section :
- The documentation section defines the set of comment lines (/* */) or ( // ). For example, it might be the name of the program or author and other details for feature reference we can define this section.
- The Compiler ignore commands when compiling because commands only for the purposes of others understanding the codes.
- Comment can be used anywhere in the program
C Syntax
Programming Example :
2. Link section :
- The link section provides instructions to the compiler to link functions from the system library.
C Syntax
3. Common header files are
- The commands in these section are called preprocessor commands
- stdio- standard input /output function
- conio- console input/output function
- math-contains math function like (cos(),sin(),sqrt(),abs()).
Programming Example :
Read Also
C Structure4. Definition section :
- In this definition section we can defines all symbolic constants.
C Syntax
Programming Example :
5. Global declaration section :
- The variables that are used in more than one function. Such variables are called global variables. And in general we can call the global variable outside the function.
C Syntax
Programming Example
6. main () function section :
- The main() is the main function where program execution begins.
- Thats why every C-Program must have one main() function section and the main function is divided into two parts they are
- Declaration part
- Executable part
7. Declaration part :
- In this declaration part we declare all the variables that are used in the executable part.
C Syntax
Programming Example
8. Executable part :
- In this executable part section, the execution begins at the opening brace and ends at the closing brace.
- The closing brace of the main function is the logical end of the program. All statements in the declaration and executable part ends with a semicolon.
9. Subprogram section :
- The subprogram section contains all the user-defined functions that are called in the main () function.
- User-defined functions are generally placed immediately after the main () function, although they may appear in any order.