Devil
04-01-2002, 11:16 AM
#include <stdio.h>
#include <math.h>
main()
{
int i;
int j;
printf("%d\n", 2);
for (i=3; i<=100; i=i+1)
{
for (j=2; j<i; j=j+1)
{
if (i % j == 0)
break;
if (j > sqrt(i))
{
printf("%d\n", i);
break;
}
}
}
return 0;
}
the error I get when I try to compile the code is:
/tmp/cczI2jIi.o: In function `main':
/tmp/cczI2jIi.o(.text+0x74): undefined reference to `sqrt'
collect2: ld returned 1 exit status
I don't understand why it wont compile..
#include <math.h>
main()
{
int i;
int j;
printf("%d\n", 2);
for (i=3; i<=100; i=i+1)
{
for (j=2; j<i; j=j+1)
{
if (i % j == 0)
break;
if (j > sqrt(i))
{
printf("%d\n", i);
break;
}
}
}
return 0;
}
the error I get when I try to compile the code is:
/tmp/cczI2jIi.o: In function `main':
/tmp/cczI2jIi.o(.text+0x74): undefined reference to `sqrt'
collect2: ld returned 1 exit status
I don't understand why it wont compile..