Introduction
void main()
{
int i=10,j=20;
j=i+j-(i=j);
}
Here the two variables are swapped in a single statement . The cost is reduced than the known swapping methods.
- Temporary variables are not used.
- addition and subtraction only.
- can be used for any data types and this is efficient than the normal methods.
- time is saved.
- space is saved.
- complexity reduced.