Skip to content

Instantly share code, notes, and snippets.

@AhmedHelalAhmed
Created December 2, 2017 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AhmedHelalAhmed/3b8ff363fbf8db837dcb3caac07e562f to your computer and use it in GitHub Desktop.
Save AhmedHelalAhmed/3b8ff363fbf8db837dcb3caac07e562f to your computer and use it in GitHub Desktop.
swap by reference
#include <iostream>
using namespace std;
void Swap (int& x,int& y);
int main()
{
int a=3,b=4;
Swap(a,b);
cout<<"a= "<<a<<endl;
cout<<"b= "<<b;
return 0;
}
void Swap (int& x,int& y)
{
int temp;
temp=x;
x=y;
y=temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment