$2^{24} = (1000000000000000000000000)_2$
if(!(n & 1))
printf("*");
n = n >> 1;
(n & 1) will not be true until $n = 1$
and statement under if will execute whenever (n & 1) is not true
hence * will be printed 24 times, until the $2^{24}$ becomes 1.
There are 24 zeros in n and each iteration result in 1 right shift and also print $*$