Examveda

What will be the output of the following C++ code?
#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: Option C


Join The Discussion

Related Questions on Standard Template Library (STL) in C plus plus