Program to swap the value of two integer using pointer.

void main()
{
int a,b;
int *pa,*pb,*temp;
clrscr();
printf("Enter the 2 values");
scanf("%d",&a,&b);
printf("Before swapping :a=%d b=%d",a,b);
pa=&a;
pb=&b;
temp=pa;
pa=pb;
pb=temp;
printf("After swapping:a=%d b=%d",&8pa,8pb);
pb=temp;
getch();
}

No comments:

Post a Comment