title: The difference between n++ and ++n at the end of a while loop? (ANSI C)
body: <p>this is probably a dumb question but I just can't figure it out. It has to do with the differences between n++ and ++n (which I thought I understood but apparently not).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  long algorithmA(int n);
  long algorithmB(int n);
  
  int main(){
      long A, B;
      A = B = 0;
      int n = 1;
      while(A &gt;= B){
          A = algorithmA(n);
          B = algorithmB(n);
          n++;
      }
      printf("At n = %d, Algorithm A performs in %ld seconds &amp; "
             "Algorithm B performs in %ld seconds.", n, A, B);
  
  }
  
  long algorithmA(int n){
      return pow(n,4) * 86400 * 4;
  }
  
  long algorithmB(int n){
      return pow(3,n);
  }
  </code></pre>
  
  <p>Here you can probably tell I'm trying to see at what point Algorithm A outperforms Algorithm B. The functions and units of time were given to me in a homework problem. </p>
  
  <p>Anyways, I always thought that the order of "++" would not matter at the end of a while loop. But if I put ++n instead of n++, I get the wrong answer. Can somebody explain why?</p>
  
  <p>Edit: Well it WAS showing 24 with ++n and 25 with n++, but it must have been for another reason. Because I just checked now and there is no difference. Thanks for your patience and time guys, I just wish I knew what I did!</p>