pow() function not working

September 8, 2012 at 04:39:49
Specs: Linux x86_64
My code is :
#include<stdio.h>
#include<math.h>
#include<signal.h>
int main()
{
int T,a,b,n,i,s1=0,l,s2=0,sum,c[1001]={0};
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&a,&b);
scanf("%d",&n);
l=n;
for(i=0;i<n+1;i++)
scanf("%d",&c[i]);
for(i=0;i<n+1;i++)
{
s1=s1+(c[i]*pow(a,l));
l--;
}
l=n;
for(i=0;i<n+1;i++)
{
s2=s2+(c[i]*pow(b,l));
l--;
}
sum=s1+s2;
printf("%d\n",(sum%1000000007));
}
return 0;
}


Now when i compile the error shown is :
user@host# gcc -lm 9.c
/tmp/ccv07Xvw.o: In function `main':
9.c:(.text+0x113): undefined reference to `pow'
9.c:(.text+0x1a0): undefined reference to `pow'
collect2: ld returned 1 exit status


.... So please help me with this problem as soon as possible....
Thanks in advance


See More: pow() function not working

Report •

#1
September 8, 2012 at 05:46:07
Is pow an array?


====================================
Life is too important to be taken seriously.

M2


Report •

#2
September 8, 2012 at 07:05:11
No pow(a,b) is a function "a power b"

Report •

#3
September 8, 2012 at 07:24:11
If you're linking the math library, and the linker can't find pow(), I'd suspect your library is corrupt.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 8, 2012 at 07:50:15
So what can i do to reinstall the library? :|

Report •

#5
September 8, 2012 at 08:02:26
I don't use Linux, so I don't know how you install software. apt-get? aptitude?

How To Ask Questions The Smart Way


Report •

#6
September 8, 2012 at 15:35:29
You probably have a problem linking in the correct library. Check out this link:

http://linux.die.net/man/3/pow

This looks like it will work:

cc -lm x.c -o xx


Report •

#7
September 10, 2012 at 05:11:10
The problem is still not resolved :(

Report •

#8
September 10, 2012 at 06:11:20
Not resolved after reinstalling gcc?

How To Ask Questions The Smart Way


Report •

Ask Question