Code Competitions

Coding competition
Showing posts with label swap using pass by address. Show all posts
Showing posts with label swap using pass by address. Show all posts

Wednesday, 12 June 2013

program to swap by using pass by address

#include<iostream.h>
#include<conio.h>
void main()
{
    int a,b;
    clrscr();
    void swap(int *,int *);
    cout<<"enter the value of a and b ";
    cin>>a>>b;
    swap(&a,&b);
    cout<<"the value of a is "<<a<<" and b is "<<b;
    getch();
}
void swap(int *c,int *d)
{
    int a;
    a=*c;
    *c=*d;
    *d=a;
}