Value being passed to the function is locally stored by the function parameter in stack memory location. If you change the value of function parameter, it is changed for the current function only. It will not change the value of variable inside the caller method. In which original value is not modified.
e.g:#include<iostream.h> #include<conio.h> void swap(int,int); void main() { int a,b; cout<<"Enter values for a "; cin>>a; cout<<"Enter values for b "; cin>>b; swap(a,b); getch(); } void swap(int p,int q) { int temp; temp=p; p=q; q=temp; cout<<"After swap a = "<<p<<" and b = "<<q; }O/P
Enter value for a 3 Enter value for b 4 After swap a=4 and b=3