Tuesday 30 September 2014

Structure of C

Structure of C language

Before stating in c programming,we must to know structure of c. it is very important. 
                 C program is a collection of one or more functions. Every function is a collection of statement and perform some specific task. The general structure of C.


Comments

preprocessor 
global variable
main() function
{
local variable
statements
...............
..............
................
}


function( )

{
local variables
statements
................
...............
}


function 2 ( )

{
local variables
statements
........
........
...........
}



Comment can be placed anywhere in a program and are enclosed between the delimiter /* and */ . this is called single line comment. // this is called multiple line comment. comment are generally used for documentation purposes.


prepossor directive are processed through prepocessor before the C source code passes through compiler. The commonly used preposser directive are #include and #define. # include is used for including header files. #define is used to define symbolic constants and macros.

Every C program has one or more functions.if a program has only one function then it must be main( ). Execution of every C program starts with main( ) function. it has two parts, declaration of local variables and statements. The scope of the local variable is local to that function only. Statement in the main () function are executed one by one. Other function are the user defined functions, which also have local variable and C statements.they can be defined before or after main(). It may be possible that some variable have to be used in many function, so it is necessary to declare them globally. These variable are called global variables.

No comments:

Post a Comment