Finding n.o of setbits between 2 n.os

please comment and correct my code
i cant understand why i am not getting any output its basically running infinitely ,.
my code
https://ide.codingblocks.com/s/40996

questn link
https://hack.codingblocks.com/contests/c/512/102

Heyy Jai !
Actually your internal while loop is working on variable j so it results j to be zero everytime which causes this to infinite looping .
Just modify it , your code will work .
If you want to see ur modified code , check here
https://ide.codingblocks.com/s/41021

https://ide.codingblocks.com/s/40996

i cant see the reason why my code wont work
please correct my code
the one that u gave me is simply a different way of solving but i wanna solve this way

Suppose a=0 then everytime j becomes zero because of while loop which causes infinite loop .
See the working with one example , you will understand

but i have placed the conditon >0 in the loop so for number 0 the loop wont run infinitely

anyways its not running infinitely i checked and
CAN U PLEASE COMMENT AND CORRECT MY CODE

it would be very helpful

OKay , Check this
https://ide.codingblocks.com/s/41068