#include <iostream> using namespace std; void swap(int &x, int &y) //passing the reference { int temp; temp = x; x=y; y = temp; } int main() { int a, b; a=10; b=20; swap(a,b); cout << "a = "<<a <<", b = "<<b << endl; //a = 10, b = 20 return 0; }
#include <iostream> using namespace std; void swap(int &x, int &y) //passing the reference { int temp; temp = x; x=y; y = temp; } int main() { int a, b; a=10; b=20; swap(a,b); cout << "a = "<<a <<", b = "<<b << endl; //a = 10, b = 20 return 0; }