Complete the code to invert all bits of the variable num using the NOT operator.
unsigned int num = 0x0F; unsigned int inverted = [1] num;
~. It flips every bit of the number.Complete the code to invert bits of value and store the result in result.
unsigned char value = 0xAA; unsigned char result = [1]value;
~ operator inverts all bits of the operand.Fix the error in the code to correctly invert bits of data.
unsigned int data = 0x1234; unsigned int inverted = [1]data;
! returns 0 or 1, not bitwise inversion. Use ~ for bitwise NOT.Fill both blanks to create a mask and invert only the lower 4 bits of num.
unsigned int num = 0x3C; unsigned int mask = [1]; unsigned int result = num [2] mask;
0x0F with 1s in the lower 4 bits. XOR (^) the number with this mask inverts exactly those bits (XOR with 1 flips a bit, XOR with 0 leaves it unchanged).Fill the blanks to invert bits of value only where mask has 1s, leaving other bits unchanged.
unsigned int value = 0x55AA; unsigned int mask = [1]; unsigned int result = value [2] mask; // result now has bits inverted only where mask bits are 1
0x00FF to target the lower 8 bits. XOR (^) flips bits where mask is 1.