#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
double d;
printf("Please input the smallest number : ");
// Ask the user to enter the smallest number
scanf("%le", &d);
// save the value
int n=1;
int i=1;
double pi=4/(2 * i - 1) * pow(-1,i + 1);
double minvalue = 4/((2*(n+1))-1);
// declare the values
while(fabs(minvalue) >= d){
// Using fabs() to return the absolute value
minvalue = 4.0/((2*(n+1))-1);
// useing the formula
n++;
// printf("%d",n);
}
int k = 2;
for(; k <= n; k++){
// we already calculate once before, so k = 2
pi = pi + 4.0/(2 * k - 1) * pow(-1,k + 1);
}
printf("The value of pi is:%f\n",pi);
return 0;
}
当我使用&#34; gcc -o main main.c&#34;在unix中发表评论,它出现了:
Undefined first referenced
symbol in file
pow /var/tmp//ccaESiRZ.o
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
任何解决方案?