unsigned integer is 64 bits long. hmmmm $2^{40}$ won't cause overflow concerns.
for( i=n; i>1; i=i/2) j++;
This loop will run for k iteration( which pass test condition), what this k is?
$\frac{n}{2^k}=1$ gives $k=log_2n$.
So, for n=$2^{40}$ times, my k=40 and value of j will be 40(j will be incremented by 1 "k times" ).
for( ; j>1; j=j/2) sum++;
till $\frac{j}{2^r}>1$ this loop will continue to run and $r$ is the number of iterations.
this will run for $\lfloor log_240 \rfloor=5$ times.
$40->20->10->5->2$ for these values of j loop will run
hence sum=5.
Answer (B)