Created
December 2, 2017 12:04
-
-
Save AhmedHelalAhmed/3b8ff363fbf8db837dcb3caac07e562f to your computer and use it in GitHub Desktop.
swap by reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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