edited by
486 views
0 votes
0 votes
what is the  value of z?

#include <stdio.h>
int main() {
    int a[]={3,5,6,4};
    int z=0;
    for (int y=0;y<(sizeof(a)/sizeof int);y++)
        z=a[y]+value(a[y]);
}
int value(int *x)
{
    static int count;
    while(*x)
   {
       count=count+*x&1;
        *x>>1 ;
   }
}
edited by

1 Answer

Best answer
0 votes
0 votes
I think the answer is 11

as the count variables count the number of 1 in the binary representation of array elements.
selected by

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
tishhaagrawal asked Dec 16, 2023
311 views
Below is my approach to solving this question, can anyone please explain if I am doing it the right way?Let X = #free slotssince, m =7 and n = 3So, $4 \leqslant x\leqsla...
0 votes
0 votes
1 answer
4
jugnu1337 asked Oct 22, 2023
333 views
Suppose A is a 12 by 9 incidence matrix from a connected (but unknown) graph with 9 nodes and 12 edges. The diagonal entries of $A^{T}.A$give the number of edges into eac...