This is my code:
Code:
#include <math.h>
#include <stdio.h>
int main(void)
{
float a,b,c,root_1,root_2;
printf("Please enter value a from the quadratic equation \n");
scanf("%f",&a);
printf("Please enter value b from the quadratic equation \n");
scanf("%f",&b);
printf("Please enter value c from the quadratic equation \n");
scanf("%f",&c);
double disc = pow(b,2) - 4*a*c;
if ((disc)>0)
{
root_1 = (-b + sqrt(disc))/(2*a);
root_2 = (-b - sqrt(disc))/(2*a);
printf("\n The first root is %.2f",root_1);
printf("\n The second root is %.2f",root_2);
}
else
{
printf("\n The roots are imaginary because the discriminant is negative!");
}
return 0;
}
And I keep getting this error:
Code:
/tmp/ccgtUIun.o: In function `main':
assign345.c:(.text+0xc7): undefined reference to `sqrt'
assign345.c:(.text+0xef): undefined reference to `sqrt'
collect2: ld returned 1 exit status
PLEASE HELP!!!