Doubt in getbit()

in the function getbit(), can you explain the statement “n&mask>0 ? 1:0” as I not familiar with this syntax

hello @gautam74

its a ternary operator.

condition? instruction1 : instruction2 ;

if condition is true then instruction1 will exectue otherwise instruction2 will execute.

here the condition we have is n & mask > 0 . if this cinditon will be true then 1 will be returned otherwise 0

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.