Tuesday, February 3, 2015

Structure of a C Program

C Programming
 
Structure of a C Program :
Include header file section
Global declaration section
main()
{
Declaration part
Executable part
}
User-defined functions
{
Statements
}


Include Header File Section:
C program depends upon some header files for function definition that are used in program.
Each header file by default is extended with .h. The header file should be included using # include
directive as given here.
Global Declaration :
This section declares some variables that are used in more than one function. These variables
are known as global variables. This section must be declared outside of all the functions.
Function Main :
Every program written in C language must contain main () function. The function main() is
a starting point of every C program. The execution of the program always begins with the function
main ().
Declaration Part :
The declaration part declares the entire variables that are used in executable part. The
initializations of variables are also done in this section. Initialisation means providing initial value
to the variables.
Executable Part :
This part contains the statements following the declaration of the variables. This part conatins
a set of statements or a single statement. These statements are enclosed between the braces.
User Defined Function :
The functions defined by the user are called user-defined functions. These functions are
generally defined after the main () function.

No comments:

Post a Comment