Could you please explain how every digit is saved in n..i mean n is assigned a different value at the end but how come after the loop is over the bit which is turned off is saved

question:
set even bits of a number to 0

answer:

hello @aarijrab

a) image

this line will generate a mask whose ith bit will be 1 and rest all bit will be 0.
now
image
this line will compute negation i.e it will convert all 0 bit 1 and 1 bit 0.
and becuase mask has only ith bit set and all other are 0, on taking negation it will have ith bit as 0 and rest all bit will be 1.

after this
image

when we will take & of mask with n , it will turn of ith bit ,because ith bit of mask is 0 (and of 0 with anything is 0).
so after this line ith bit of n will become 0.

and because i is going from 0 to 31 ,it will set all bit of n to zero.