say n= 1101
now if n&01 means we will do bitwise and with n and 1.i.e,
1101 & 0001 ..now in this example the unit's place of n has 1 so 1&1 will give 1 here and hence if(1) will be true so we will increment x by 1.
now n>>=1 means n=n>>1 so will do right shift on n until n is completely exhausted i.e, n becomes 0000. so
according to our example,
1st right shift : 0110 & 0001 => 0 as 0&1 is 1=0 so x will remain 1
2nd right shift: 0011 & 0001=> 1 and x is now 2
3rd right shift: 0001 & 0001 =>1 and x is now 3
4th right shift: n becomes 0000 so while(n!=0) condition fails and we exit from the loop..
now x=3 i.e the total no of set bits or 1 in i/p stream so ans is A