Wednesday, October 19, 2011

Program:To swap the numbers using call by address




CODE:

#include<iostream.h>
#include<conio.h>
void swap(int*,int*);
void main()
{
clrscr();
int a,b;
cout<<”Enter two numbers :  “;
cin>>a>>b;
swap(&a,&b);
cout<<”Swapped numbers are(call by address) : ”;
cout<<a<<”  “<<b;
getch();
}
void swap(int *a,int *b)
{int z;
z=*a;
*a=*b;
*b=z;
}


Article by
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

0 comments:

Post a Comment