1

When I compile the below code with gcc complier it gives me error:

/tmp/ccQ7MdHf.o: In function isPrime': source.c:(.text+0x66): undefined reference tosqrt' collect2: error: ld returned 1 exit status

int isPrime(int n) //function to check passed number is prime or not
{
    int i;

    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i == 0)
        {
            return 0; //if number is not prime return 0
        }
    }
    return 1; //if number is prime return 1
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
ImSooCool
  • 11
  • 1

0 Answers0