EmbLogic's Blog

SWAP THE THREE VALUES WITHOUT USING FOURTH VARIABLE

#include<stdio.h>

int main()
{
int a=5;
int b=6;
int c=7;

a^=b,b^=a,a^=b;
b^=c,c^=b,b^=c;

printf(“a= %d\n”,a);
printf(“b= %d\n”,b);
printf(“c= %d\n”,c);

return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>