Gate CS-2007 Question Paper With Solutions

Q. 13 Consider the following C code segment:

int IsPrime (n)
    {
        int i, n;
        for (i=2; i<=sqrt(n);i++)
            if(n%i == )
                {printf("Not Prime \n"); return ;}
        return 1;
    }

Let T(n) denotes the number of times the for loop is executed by the program on input n.

Which of the following is TRUE?

Gate CS-2007 Question Paper With Solutions

Answer: (B)

Explanation:

Gate CS-2007 Question Paper With Solutions

Learn More:   Gate CS-2004 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here