Friday, January 27, 2012

Functions and Parameters

Syntax of function 
Declaration section
<<Returntype>> funname(parameter list);
Definition section
<<Returntype>> funname(parameter list)
{
body of the function
}
Function Call
Funname(parameter);

Example function
   #include<stdio.h>
void fun(int a);  //declaration
int main()
{
  fun(10);  //Call
} 
void fun(int x)  //definition
{
  printf(“%d”,x); 
}
Actual and Formal parameters
Actual parameters are those that are used during a function call
Formal parameters are those that are used in function definition and function declaration