Question 9
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
printf("%d %d\n", (16 & 15) == 0, (18 & 17) == 0);
return 0;
}
- A 1 0 Correct
- B 0 1
- C 1 1
- D 0 0
Correct Answer: Option A
16 = 10000 and 15 = 01111 share no bits, so the AND is 0: a power of two. 18 = 10010 and 17 = 10001 share the top bit (16), so 18 is not a power of two.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!