title: Declaring sqrt(var) as a compile time constant in c++
body: <p>I have a c++ program where I need to pass the square root of a number in a for loop.</p>
  <pre><code>
  #include&lt;random&gt;
  #include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  #include&lt;string&gt;
  #include&lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;omp.h&gt;
  
  using namespace std;
  int main()
  {
  vector&lt;int&gt;inputDataBits(49);                                    // vector of randomly generated input data bits
  #ifdef printDebug
      std::cout &lt;&lt; &quot;the input data bits are&quot; &lt;&lt; endl;
      std::cout &lt;&lt; &quot;-------------------------&quot; &lt;&lt; endl &lt;&lt; endl;
      int var =49;
      const int r=(int)sqrt(var);
      float input2d[r][r];
      for (int i = 0; i &lt; r; i++)
      {
          for (int j = 0; j &lt; r; j++)
          {
              input2d[i][j] = inputDataBits[(j %r) + (i *r)];
              std::cout &lt;&lt; input2d[i][j] &lt;&lt; &quot;\t&quot;;
          }
          std::cout &lt;&lt; endl &lt;&lt; endl;
      }
      std::cout &lt;&lt; endl &lt;&lt; endl;
  #endif
  return 0;
  }
  </code></pre>
  <p>I get an error 'expression must have a constant value'. Is there a way to do this in c++?</p>