Tuesday 24 February 2015

Call by Reference in C++

#include<iostream.h>
#include<conio.h>
void swap(int*,int*);
main()
{
int a=10,b=20;
clrscr();
swap(&a,&b);
cout<<"\n A Value is :"<<a;
cout<<"\n B Value is :"<<b;
getch();
}
void swap(int *x,int *y)
{
int *t;
*t=*x;
*x=*y;
*y=*t;
}

No comments:

Post a Comment