Solution Review: Turn On the 3rd and 5th Bits
Understand how to turn on specific bits in an integer using bitwise operators in C. This lesson guides you through selecting the correct mask and using the OR operator to modify the 3rd and 5th bits without affecting others.
We'll cover the following...
We'll cover the following...
Solution
RUN the code given below and see its output!
Explanation
To turn on the bit, first, we have to select the appropriate mask value based on the value that should be turned on.
Lines 36-38: If you want to turn on the bit, then the ...