Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void swapTwoNums(int &a, int &b){
- int c = a; // c = 5, a = 5
- a = b; // a = 10, b=10
- b = c; //b = 5, a = 10
- }
- int main(){
- int a = 5, b =10;
- swapTwoNums(a,b);
- cout<<"a = "<<a<<" b = "<<b<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement