在vi中调用sqrt()函数出错。

作者: yangzihy 2005-05-23 08:12:35
在vi中调用sqrt()函数,用gcc调试时提示:undefined reference to 'sqrt' , collect2:id returned 1 exit status,请问这是什么问题,谢谢。

#include
main()
{
float a,b,c,disc,x1,x2,p,q;
scanf("a=%f,b=%f,c=%f",&a,&b,&c);
disc=b*b-4*a*c;
p=-b/(2*a);
q=sqrt(disc)/(2*a);
x1=p+q;x2=p-q;
printf("\n\nx1=%5.2f\nx2=%5.2f\n",x1,x2);
}

undefined reference to 'sqrt'
collect2:id returned 1 exit status

相关资讯