HOW is if(j&1) used for checking for odd no.
time: 01:24:25
HOW is if(j&1) used for checking for odd no
Numbers are stored binary numbers, and all odd numbers have least significant bit 1, so odd &1 =1 and even&1=0 (as least significant bit is 0 for even number, and 1 has only 1 bit, eg 2&1=0(10&1)).
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
and why do we need cin.ignore(); i tried without it is only taking n-1 string even when i made the code run for n times.