/*
Write a function using reference variables` as arguments
to swap the values of a pair of integers.
*/
#include<iostream>
using namespace std;
void swap(int &a,int &b)
{
int temp=a;
a=b;
b=temp;
}
int main()
{
int a=10,b=20;
cout<<"\n\n Before Swap: ";
cout<<"\n A: "<<a;
cout<<"\n B: "<<b;
swap(a,b);
cout<<"\n\n After Swap: ";
cout<<"\n A: "<<a;
cout<<"\n B: "<<b;
return 0;
}
Write a function using reference variables` as arguments
to swap the values of a pair of integers.
*/
#include<iostream>
using namespace std;
void swap(int &a,int &b)
{
int temp=a;
a=b;
b=temp;
}
int main()
{
int a=10,b=20;
cout<<"\n\n Before Swap: ";
cout<<"\n A: "<<a;
cout<<"\n B: "<<b;
swap(a,b);
cout<<"\n\n After Swap: ";
cout<<"\n A: "<<a;
cout<<"\n B: "<<b;
return 0;
}