0 0 votes int main() { int n = 3,i,count=0; for(i=0;i<1<<n;i++) { int p = i; while(p) { int k = p & -p; p = p - k; count++; } } } The value of count variable after execution of the above code? The value of count variable when $n = m$ ? [EDITED] Programming in C programming-in-c bitwise-operations + – dd 1.5k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
3 3 votes hope it helps....... akash.dinkar12 answered Apr 20, 2017 akash.dinkar12 comment Share Follow See all 6 Comments 6 6 Comments reply akash.dinkar12 commented Apr 20, 2017 reply Follow flag In B part of this question, Value of count may be depend upon where u are fixing this statement n=m........ count ,might be 2 but not sure about it...... 0 0 replyShare dd commented Apr 20, 2017 reply Follow flag for $n = m$; count = $m \cdot 2^{m-1}$ 1 1 replyShare dd commented Apr 20, 2017 reply Follow flag https://gateoverflow.in/93518/time-complexity-and-output This is actually the same program (although slow compared to above). 1 1 replyShare dd commented Apr 20, 2017 reply Follow flag @akash.dinkar12 : sorry: I am changing $m$ with $k$ inside the code. 1 1 replyShare akash.dinkar12 commented Apr 21, 2017 reply Follow flag ur previous code current code Output should remain same, how can replacement affect the output by only changing the name of variable.... 0 0 replyShare dd commented Apr 21, 2017 reply Follow flag I did not mean that: I changed $m$ because I also mentioned $n = m$ statement:: not to confuse , I changed $m$ with $k$ inside the code. 0 0 replyShare Please log in or register to add a comment.