0 votes 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 + – dd asked Apr 20, 2017 • retagged Jun 4, 2017 by Arjun dd 721 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
3 votes 3 votes hope it helps....... akash.dinkar12 answered Apr 20, 2017 akash.dinkar12 comment Share Follow See all 6 Comments See all 6 6 Comments reply akash.dinkar12 commented Apr 20, 2017 reply Follow Share 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 votes 0 votes dd commented Apr 20, 2017 reply Follow Share for $n = m$; count = $m \cdot 2^{m-1}$ 1 votes 1 votes dd commented Apr 20, 2017 reply Follow Share https://gateoverflow.in/93518/time-complexity-and-output This is actually the same program (although slow compared to above). 1 votes 1 votes dd commented Apr 20, 2017 reply Follow Share @akash.dinkar12 : sorry: I am changing $m$ with $k$ inside the code. 1 votes 1 votes akash.dinkar12 commented Apr 21, 2017 reply Follow Share ur previous code current code Output should remain same, how can replacement affect the output by only changing the name of variable.... 0 votes 0 votes dd commented Apr 21, 2017 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.