/*--------------- Include Section ----------------*/ #include <stdio.h> #include <stdlib.h> #include <limits.h> #include <math.h>
This is the Function with sqrt that is not working.
/*--------------------------- approx2 funtion --------------------------------
Purpose: Approximates value of pi using the square root equation
Returns: Approximate value of pi
----------------------------------------------------------------------------*/
long double approx2 (int terms) {
long double pi2;
long double num;
long double denom;
int i;
num = 12;
denom = 1;
for (i = 1; i <= terms; i++) {
if (i % 2 != 0 ) {
pi2 += num / (denom * denom);
}
else {
pi2 -= num / (denom * denom);
}
denom += 1.0;
}
pi2 = sqrt (pi2);
return pi2;
}
This is the error code.
/tmp/ccSYh7w6.o: In function `approx2': pi.c:(.text+0x2ac): undefined reference to `sqrt' collect2: ld returned 1 exit status
I cannot seem to figure out why it does not like sqrt. I have tried looking it up, but I cannot find an explanation that apperently applies.

New Topic/Question
Reply



MultiQuote





|