#include
int main (argc, char ** argv)
{
float x,y;
for (x=-2.25f; x<= 2.25f; x+=.1f)
{
y = pow(x, 2)-x);
printf("%0.2f %0.2f\n", x, y);
}
}
pow is "undefined reference to 'pow'
I needed -lm on the cc line. Thanks.
Conservative. Idaho. Software engineer. Historian. Trying to prevent Idiocracy from becoming a documentary.
Email complaints/requests about copyright infringement to clayton @ claytoncramer.com. Reminder: the last copyright troll that bothered me went bankrupt.
Was the space in the include file name "math .h" in your original source? If so, that's your error.
ReplyDeleteAlso, using quotes instead of brackets means it looks in local directory for file instead of the compiler include search path.
ReplyDeleteOoh, ooh, I know! (Maybe.)
ReplyDeleteAdd the '-lm' flag to your cc step to link in the math library.
Also "#include "
In the text shown, the parenthesis are not balanced where y is evaluated. I see an extra ) before the semicolon at the end of the expression.
ReplyDeleteDo you have a local math.h file?
ReplyDeleteThese expressions aren't allowed in The New Math. Haven't you heard?
ReplyDeleteThere's a new law coming soon, which will set Pi=3.0 That'll make everything much simpler, won't it!