Program -
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
void
swap(int,int);
a=5;
b=23;
cout<<"\n
value of a="<<a<<"and value of
b="<<b<<"before swap";
swap(a,b);
cout<<"\n
value of a="<<a<<"and value of
b="<<b<<"after the swap";
getch();
}
void swap(int
x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
return;
}
Output -
value of a=5and value of b=23before swap
value of a=5and value of b=23after the swap
0 comments:
Post a Comment