adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <stdio.h>
    #include <stdlib.h>
    int compareints (const void * a, const void * b)
    {
        return ( *(int*)a - *(int*)b );
    }
    int values[] = { 50, 20, 60, 40, 10, 30 };
    int main ()
    {
        int * p;
        int key = 40;
        qsort(values, 6, sizeof (int), compareints);
        p = (int*) bsearch (&key, values, 6, sizeof (int), compareints);
        if (p != NULL)
        printf ("%d\n",*p);
        return 0;
    }

a.

10

b.

20

c.

40

d.

30

Answer: (c).40

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?