One line swap of integers

Submitted by:David Villa

Date added:08 September, 2013

Category:C

Example shows how one line swap of integers

Tags: line swap

Code Snippet:

#include <stdio.h>

int main()
{
int a=10,b=20;
printf("A:%d B:%d\n",a,b);
a=(a+b)-(b=a); //SWAPS
printf("A:%d B:%d\n",a,b);
return 1;
}
 
 

Comments