1. How to write a swap program without using temprary variables
void main()
{
int i=2;
int j=3;
i=i^j;
j=i^j;
i=i^j;
printf("now i=%d j=%d",i,j);
}
output:
now i=3, j=2.
Explainations:
binary value of i=0000 0010
binary value of j=0000 0011
i=i ^ j --> perform the xor operations.so i=1.
j=i ^ j --> j=2
i=i ^ j --> i=3