Let me refresh. I think I fixed that error that says: expected ';' before '}' token
So this is the code I have so far:
Code:
#include <stdio.h>
#include <math.h>
int main(void) {
float x1,x2,a,b,c;
printf("Enter your values of a b c that correspond to the"
"quadratic ax^2+bx+c: \n");
scanf("%f %f %f", &a, &b, &c);
if (b*b - 4*a*c >= 0) {
x1 = (-b + sqrt(b*b-4*a*c))/(2*a);
x2 = (-b - sqrt(b*b-4*a*c))/(2*a);
printf("The solutions to your quadratic are:%f %f"
"\n",x1,x2); }
else
printf("There are no real solutions to your"
"quadratic\n");
return 0;
}
And when I try and compile it with:
Code:
gcc -Werror -Wall -O -o quadratic quadratic.c
I get these errors:
Code:
/tmp/ccykv6lI.o: In function `main':
quadratic.c:(.text+0x81): undefined reference to `sqrt'
quadratic.c:(.text+0xc1): undefined reference to `sqrt'
collect2: ld returned 1 exit status
I remember in school they told us to add -ml for math library when using #include <math.h> but when I do this as so:
Code:
gcc -Werror -Wall -ml -O -o quadratic quadratic.c
It says it doesn't recognize -ml.