Program of swapping numbers using pointers

on Monday, 20 January 2014
#include<iostream.h>
#include<conio.h>
void kal(int *a,int *b)
{
    int *temp,i;
    temp=&i;
    *temp=*a;
    *a=*b;
    *b=*temp;
}

main()
{
    clrscr();
    int i=5,j=10;
    cout<<"Before swapping I = "<<i<<" J = "<<j<<endl;
    kal(&i,&j);
    cout<<"After swapping I = "<<i<<" J = "<<j<<endl;
}

0 comments:

Post a Comment