Complete the code to check if a number is even using bitwise AND.
if ((num & [1]) == 0) { printf("Even\n"); } else { printf("Odd\n"); }
The least significant bit (LSB) of an even number is 0. Using bitwise AND with 1 checks this bit.
Complete the code to print "Odd" when the number is odd using bitwise operation.
if ((num & [1]) != 0) { printf("Odd\n"); } else { printf("Even\n"); }
Bitwise AND with 1 checks if the least significant bit is set, indicating an odd number.
Fix the error in the code to correctly check if a number is even using bitwise operation.
if ((num [1] 1) == 0) { printf("Even\n"); } else { printf("Odd\n"); }
The bitwise AND operator (&) is used to check the least significant bit.
Fill both blanks to complete the function that returns 1 if number is even, else 0.
int isEven(int num) {
return (num [1] 1) [2] 0;
}The function uses bitwise AND to check the last bit and compares it to zero to determine evenness.
Fill all three blanks to complete the code that prints if a number is even or odd using bitwise operations.
int num = 7; if ((num [1] [2]) [3] 0) { printf("Odd\n"); } else { printf("Even\n"); }
The code uses bitwise AND with 1 to check the last bit and compares if it is not equal to zero to print "Odd".
