Trying to compile some code on my debian machine and am getting an error. I have to trouble getting it to compile on my XP machine. Compiler is gcc on both machines.
Error is:
Code:
/tmp/ccFbD8lA.o: In function `main':
/tmp/ccFbD8lA.o(.text+0x9d): undefined reference to `sqrt'
collect2: ld returned 1 exit status
Code is:
Code:
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c, a2;
float x1, x2, part1;
printf("A: ");
scanf("%d", &a);
printf("B: ");
scanf("%d", &b);
printf("C: ");
scanf("%d", &c);
part1 = sqrt( (b*b) - 4*a*c);
a2 = 2*a;
printf("-b = %d\nB^2 - 4AC = %f\n2A = %d.\n", -b, part1, a2);
x1 = ((-b) + part1) / (2*a);
x2 = ((-b) - part1) / (2*a);
printf("X = %f\nX = %f", x1, x2);
return 0;
}