Created
November 10, 2015 16:55
-
-
Save nalin-adh/27cb9e971d0d07b2aa7b to your computer and use it in GitHub Desktop.
A C++ program that swaps data using reference variable.
This file contains 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> | |
#include<conio.h> | |
using namespace std; | |
void swap(int &,int &); | |
int main() | |
{ | |
int a,b; | |
cout<<"Enter first number : ";cin>>a; | |
cout<<"Enter second number : ";cin>>b; | |
swap(a,b); | |
cout<<"After Swap !!!"; | |
cout<<"\nFirst number is "<<a; | |
cout<<"\nSecond number is "<<b; | |
getch(); | |
return(0); | |
} | |
void swap(int &x,int &y) | |
{ | |
int z=x; | |
x=y; | |
y=z; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment