swap function

closed account (G60iz8AR)
How to find the swap function ?
#include <iostream>
#include <string>
using namespace std;

// YOU WRITE THe SWAP FUNCTION PROTOTYPE HERE


int main ()
{
int x,y;
cout << "Enter a two small positive numbers: ";
cin >> x >> y;
cout << "Before swap: x=" << x << " y= " << y << endl;
// swap( x , y );
cout << "After swap: x=" << x << " y= " << y << endl;

return 0;
}


// YOU WRITE THe SWAP FUNCTION BELOW
um...

1
2
int y(1), x(0);
swap(x, y); //x and y are swapped... 


Mabey you want to rephrase?
Topic archived. No new replies allowed.