title: increment a loop by power of 2
body: <p>I know this is a very simple thing but I cant figure out how to increment the loop by powers of two. The program is comparing insertion sort and merge sort and n should increment in powers of ie 2, 4, 8, 16, 32.... This is what I have </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  using namespace std;
  
  
  int main()
  {
      int a,n,b;
      double mergesort;
      double insertionsort;
  
      cout &lt;&lt; "Enter a and b values ";
      cin &gt;&gt; a &gt;&gt; b;
  
      do
      {
          for(n=2; n=pow(n,++);
          {
          insertionsort = a*pow(n,2);
          mergesort = b*n*log2(n);
          }
  
          cout &lt;&lt;"insertion sort= " &lt;&lt; insertionsort &lt;&lt; "merge sort= " &lt;&lt;mergesort;
          cout &lt;&lt;"n" &lt;&lt; n;
  
      }while(insertionsort &lt; mergesort);
  
      cout &lt;&lt; "Value of n that insertion beat merge sort is " &lt;&lt; " n ";
  }
  </code></pre>