title: Swapping array elements without temporary variable
body: <p>When I use following code for swapping in quick-sort it is working.</p>
  
  <pre><code>void s(int *a, int *b)
  {
     int t = *a;
     *a = *b;
     *b = t;
  }
  </code></pre>
  
  <p>But when I use following code to swap elements for quick-sort, it is not working.</p>
  
  <pre><code>void s(int *a, int *b)
  {
      *a = *a + *b;
      *b = *a - *b;
      *a = *a - *b;
  }
  </code></pre>
  
  <p>I can't figure out what is wrong with the code. </p>
  
  <p>I am adding my quick-sort code below for clarification.</p>
  
  <pre><code>void  qs(int *a, int l, int h){
     if( l&lt;h){
        int pi = pa(a, l, h);
        qs(a, l, pi-1); qs(a, pi+1, h);       
     }
  }
  int pa(int *a, int l, int h){
      int p = a[h], lt = l-1, i;
      for(i=l; i&lt;=h-1; i++) if(a[i]&lt;=p) s(&amp;a[++lt], &amp;a[i]);         
      s(&amp;a[lt+1], &amp;a[h]);
      return lt+1;        
  }
  </code></pre>