Pass by value
- A copy of the actual parameter is passed to the function.
- Changes made inside the function do not affect the original variable.
- Example:
void fun(int x) { x = 10; }Pass by Reference
- The address of the actual parameter is passed.
- Changes are made inside the function affect the original variable.
- Example:
void fun(int *x) { *x = 10; }