Welcome to Techtrip. In this channel we going to study many example of c programming language.
Here to get the answer in proper order, we are dividing the number first by 2^15, then 2^14 then 2^13,and so on upto 2^0. This logic is implemented in the for loop. 2^15 is selected because the size of int data type is 16-bits. i.e. from bit 0 to bit 15.
In this for loop we start the value of i from 15 and reach to 0.
We have taken the quotient to get the required bit and we repeat the same thing with the remainder of the division.