Answer:
Following are the program in the C++ Programming Language.
#include <iostream>
//header file
using namespace std;
//using namespace
void swapints(int &j, int &k){
//definition of the function
int temp;
temp = j;
j = k;
k = temp;
}
// function declaration
void swapints(int &j, int &k);
int main() {
// local variable declaration:
int j = 15;
int k = 23;
std::cout << "Before the swapping, value of j : "<<j<<endl;
std::cout << "Before the swapping, value of k : "<<k<<endl;
/* calling a function to swap the values using variable reference.*/
swapints(j, k);
std::cout << "After the swapping, value of j : "<<j<< endl;
std::cout << "After the swapping, value of k : "<<k<< endl;
return 0;
}
Output:
Before the swapping, value of j : 15
Before the swapping, value of k : 23
After the swapping, value of j : 23
After the swapping, value of k : 15
Explanation:
Here, we define the header fine and namespace <iostream> and "std".
Then, we define a function named "swapints()" and pass two reference variables in parameter.
Then, inside the function, we perform the codes of swapping.
Then, we define the main() function inside it we define two integer variable "j" and "k" assign value "j" to 15 and "k" to 23 and print both the variables.
Then, inside main() function we call the function "swapints()" and pass value to its parameters.