This is problem: Write a C program that reads the coefficients of a quadratic equation and prints its roots with two decimal points.
My code:
#include<stdio.h>
#include<math.h>
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; 
}
These are the errors:
/tmp/ccYLQQBg.o: In function main':
hello.c:(.text+0x61): undefined reference tosqrt'
hello.c:(.text+0xc9): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
How can I fix that? What is the problem with my code? Thanks :) the new code :
#include<stdio.h>
#include<math.h>
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",&a,&b,&c);
   printf("%f %f\n",root1,root2);
   return 0; 
}
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.
 
     
     
    