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
Is pow an array?
====================================
Life is too important to be taken seriously.M2
No pow(a,b) is a function "a power b"
If you're linking the math library, and the linker can't find pow(), I'd suspect your library is corrupt.
So what can i do to reinstall the library? :|
I don't use Linux, so I don't know how you install software. apt-get? aptitude?
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
The problem is still not resolved :(
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |