Swapping of two numbers without arithmatic operator without temporary variable
#include<stdio.h>
void swap(int *a,int *b)
{
*a^=*b^=*a^=*b;
}
int main()
{
int a=10,b=20;
swap(&a,&b);
printf("%d %d",a,b);
getch();
return(0);
}
void swap(int *a,int *b)
{
*a^=*b^=*a^=*b;
}
int main()
{
int a=10,b=20;
swap(&a,&b);
printf("%d %d",a,b);
getch();
return(0);
}
Comments
Post a Comment