Thursday, March 11, 2010

How to pass parameters in the function in C



In c we can pass the parameters in a function in two different ways.



(a)Pass by value: In this approach we pass copy of actual variables in function as a parameter. Hence any modification on parameters inside the function will not reflect in the actual variable. For example:



#include

int main(){

int a=5,b=10;

swap(a,b);

printf("%d %d",a,b);

return 0;

}

No comments:

Post a Comment