154. Design a swap function for swapping of two number.

 #include<stdio.h>

int i=10,j=20;

void swap(int *,int *);

void main()

{

    printf("Before swapping :%d %d\n",i,j);

    swap(&i,&j);

    printf("Before swapping :%d %d\n",i,j);

}

void swap(int *p,int *q)

{

    *p=*p^*q;

    *q=*p^*q;

    *p=*p^*q;

}

Comments