Answer:
The program to this question can be given as:
Program:
#include <iostream> //header file
using namespace std; //using namespace.
void SwapValues(int* userVal1, int* userVal2); //function declaration.
void SwapValues(int* userVal1, int* userVal2) //function definition.
{ //function body.
//perform swapping
int t = *userVal1;
*userVal1 = *userVal2;
*userVal2 = t;
}
int main() //main method
{
int n1, n2; //define variable
cout<<"Enter first number :"; //message
cin>>n1; //input by user.
cout<<"Enter second number :"; //message
cin>>n2; //input by user.
SwapValues(&n1,&n2); //calling function.
cout<<"Swapped values"<<endl;
cout<<"first number is :"<<n1<<endl; //print value
cout<<"second number is:"<<n2<<endl; //print value
return 0;
}
Output:
Enter first number :3
Enter second number :8
Swapped values
first number is :8
second number is :3
Explanation:
The description of the above C++ language program can be given as: