C Menu


C Program Structure




1.Documentation Section

The purpose of this section is to provide information about the program that is being written. we give this information in the form of comments which are non executable statements. By this information we can improve the readablility of the program.

There are 2 types of comment lines

  1. Single line comment
  2. Multiple line comment

1. Single line comment

It is represented using double forward slash
eg:-

// program for addition fo two numbers

2. Multiple line comment

It is represented using forward slash followed by astrick and end with astrick followed by forwardslash i.e “/*” and “*/”
eg:-

/* StudyGlance
A Fully Loaded Notebook
Best Site for B-Tech Students*/


Note: This section is optional

2. Preprocessor section

In this section we include the header files into our source program by using preprocessor command which starts with #.
Eg:-

#inlude <stdio.h> 

Note: This section is optional

3. Definition Section

This section is used for defining all the symbolic constants which is used for replacing the defined word with specific value.
Eg:-

#define   PI     3.14

it means in the program where ever we have used PI, it will be replaced with 3.14

Note: This section is optional

4. Global Declaration Section

There are some variables that are used in more than one function. Such variables are called global variables and are declared in the global declaration section that is outside of all the functions.

Note: This section is optional

5. Main Section

Every C program must have one main function. Main function is the starting point of program from where the program execution starts.

This section contains two parts declaration part and executable part.

  • 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 closing flower braces. The program 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 end with a semicolon.

eg:-
main()
{ }


6. Subprogram section

If the program is a multi-function program then 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.

Note: This section is optional



Next Topic :The C Character Set