A function can be called by two types
1) Call By Value:-
- when an original value is not modified , is known as call by value.
- In call by value the actual parameter(the parameter passed to function) is copied into the formal parameter(parameter receive by function).
- in this the value of each variable in calling function is copied into the corresponding dummy variable of the called function.
- the changes made to the dummy variable have no effect on the actual variable.
- Example:-
2)Call By Reference:-
- when an original value is modified, is known as call by reference.in this a reference is used , denoted by &(symbol).
- we can use either pointer or reference for call by reference
- in this the address of the variable is passed into the function called by actual parameter.
- in this the memory allocation is same for both actual and formal arguments.
- Example:-
Comments
Post a Comment