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(); }
For Further Reading,
0 comments:
Post a Comment