Facing Problem in Inclusion-Exclusion Principle

I watched the video of inclusion-exclusion concept. I wrote the sir’s code but I am getting wrong output. The link to code is - https://ide.codingblocks.com/s/378196 . Please tell why I am getting all wrong answers.

hello @abhaygarg2001

image

why u r doing %1
it should be setbits&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.