int a[20];
unsigned int m; // global variable
int foo(int a[]) {
int i=0,count = 0;
while(i < 20) m |= 1<<(a[i++]-1);
i = (sizeof(int)<<3)-1;
while(i>=0)
if(m&(1<<(i--))) count++;
return count;
}
In the above C code,
Array a is initialized with elements $1\leq a[i] \leq 30$ and passed to this function, output of the function foo()
is,
(Assume size of int
is $4$ bytes)
A No of distinct elements in a[]
which are more than $20$
B No of distinct elements in a[]
which less than $20$
C No of distinct elements in a[]
D None of these