Pages
Home
Adsense Tips
Blogging Tips
SEO Tips
Wordpress
Wednesday, March 12, 2014
swap numbers by using call by reference in C++
#include<iostream.h>
int swap(int &a, int &b)
{
int t=a;
a=b;
b=t;
}
int main()
{
int x=5; int y=67;
cout<<"Before swap : "<<x<<"\t"<<y<<"\n";
swap(x,y);
cout<<"\nAfter Swap: "<<x<<"\t"<<y<<"\n";
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment