
330 Fundamentals of Computer Programming and IT
void change(int a, int b)
{
int k; k=a; a=b; b=k;
cout <<“\n In function change () “;
cout<<“\n Values X=”<<a <<“ and Y= “<<b;
cout<<“\n Address X=”<<(unsigned)&a <<“ and Y= “<<(unsigned)&b;
}
OUTPUT:
Enter Values of X & Y :5 4
In function change()
Values X=4 and Y= 5
Address X=4090 and Y= 4092
In function main()
Values X=5 and Y= 4
Address X=4096 and Y= 4094
Explanation
In the above program, we are passing values of actual arguments x and y to function change(). The
formal arguments a and b of function change() receive these values. The values are exchanged
i.e., value of a is assigned to b and vice versa.