title: Finding roots of quadratic equation in c programming
body: <p>This is problem: Write a C program that reads the coefficients of a quadratic equation and prints its roots with two decimal points.</p>
  
  <p>My code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  int main() {
     float a,b,c;
     float root1;
     float root2;
     root1=(-b+sqrt(b*b-4*a*c))/2*a;
     root2=(-b-sqrt(b*b-4*a*c))/2*a;
     scanf("%f %f %f",a,b,c);
     printf("%f +f",root1,root2);
  
     return 0; 
  }
  </code></pre>
  
  <p>These are the errors:</p>
  
  <p>/tmp/ccYLQQBg.o: In function <code>main':
  hello.c:(.text+0x61): undefined reference to</code>sqrt'
  hello.c:(.text+0xc9): undefined reference to `sqrt'
  collect2: error: ld returned 1 exit status</p>
  
  <p>How can I fix that? What is the problem with my code? 
  Thanks :)
  the new code :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  int main(){
     float a,b,c;
     float root1=(-b-sqrt(b*b-4*a*c))/(2*a);
     float root2=(sqrt(b*b-4*a*c))/(2*a);
     scanf("%f %f %f",&amp;a,&amp;b,&amp;c);
     printf("%f %f\n",root1,root2);
     return 0; 
  }
  </code></pre>
  
  <p>but still there are errors. the outputs are always -nan and nan 
  if ı took out the parantesis around 2*a the outputs are -0 and 0 regardles of values of coeffiencts.</p>