Answer:
The program to this question can be given as:
Program:
#include <iostream>
//include header file (iostream).
using namespace std;
//using name space.
void swapints(int &j, int &k); // function declaration
void swapints(int &j, int &k) //function definition
{
int t; //define variable temp
//perform swapping
t = j;
j = k;
k = t;
}
int main () //define main method
{
int a = 15; //define variable.
int b = 23; //define variable.
cout <<"Before swapping"<<endl<<"value of a and b :"<<endl << a <<endl<<b;//print value.
swapints(a,b); //calling function.
cout <<endl<<"After swapping"<<endl<<"value of a and b :"<< endl << a <<endl<<b; //print value.
return 0;
}
Output:
Before swapping
value of a and b :
15
23
After swapping
value of a and b :
23
15
Explanation:
The description of the above program can be given as: