title: sqrt() function not working with variable arguments
body: <p>I don't know if I'm missing something obvious, but it appears that I'm unable to compute square roots of a <strong>variable</strong> in C; the sqrt() function only seems to work on constants. This is my code:</p>
  
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      double a = 2.0;
      double b = sqrt(a);
      printf("%f", b);
      return 0;
  }
  </code></pre>
  
  <p>When I run this program, I get the following error:</p>
  
  <pre><code>gcc -Wall -o "test2" "test2.c" (in directory: /home/eddy/Code/euler)
  /tmp/ccVfxkNh.o: In function `main':
  test2.c:(.text+0x30): undefined reference to `sqrt'
  collect2: ld returned 1 exit status
  Compilation failed.
  </code></pre>
  
  <p>However, if I replace the argument in sqrt() with a constant such as 2.0 for example, (<code>b = sqrt(2.0)</code>), then it works fine. Is sqrt() not supposed to work with variables or something?</p>
  
  <p>Thanks for the help</p>