#include <iostream.h>The output will bevoid swap1(int &a, int &b)
{
int temp = a;cout<<" Beginning of subprogram\n";a = b;
cout<<"a= " << a <<endl;
cout<<"b= " << b <<endl;
b = temp;cout<<" End of subprogram\n";}
cout<<"a= " << a <<endl;
cout<<"b= " << b <<endl;void main()
{
int i=3;
int list[5]={ 2, 0, 4, 1, 3};cout<<"Before call \n";swap1(i, list[i]);
cout<<"i= " << i <<endl;
cout<<"list[i]= "<<list[i]<<endl;
for(int j=0; j<5; j++)
cout<<list[j]<<" ";
cout<<endl;cout<<"After call \n";}
cout<<"i= " << i <<endl;
cout<<"list[i]= "<<list[i]<<endl;
for(int k=0; k<5; k++)
cout<<list[k]<<" ";
cout<<endl;
Before callThe parameter of b in subprogram was referenced to the box of list[3] at the time when the main program called the subprogram. After that, the reference to which box is not changed. Therefore, the element in list[3] is changed to the new value of b.
i= 3
list[i]= 1
2 0 4 1 3
Beginning of subprogram
a= 3
b= 1
End of subprogram
a= 1
b= 3
After call
i= 1
list[i]= 0
2 0 4 3 3