Swap the numbers using call by reference
code:
#include<iostream.h>
#include<conio.h>
void swap_ref (int &a, int &b)
{
int t=0;
t=a;
a=b;
b=t;
}
void main()
{
int x,y;
cout<<"Enter Values for x and y :\n";
cin>>x>>y;
swap_ref(x,y);
cout<<"x="<<x<<" y="<<y;
getch();
}
Article by +Jasmeet Singh
Chief-Editor
He is a tech Enthusiast, an Altruist and calm mentor. He loves to code. He is also a creative graphic designer. Do check out his designfolio @ Jasmeet.asia If you like This post, you can follow me on Twitter.
For Further Reading,
C++ Program,
Functions
0 comments:
Post a Comment