Question 2
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int tests[] = {5, 15, 25};
for (int i = 0; i < 3; i++) {
int x = tests[i];
printf("%d%d ", !(x >= 10 && x <= 20), x < 10 || x > 20);
}
printf("\n");
return 0;
}
- A 11 00 11 Correct
- B 10 01 10
- C 11 11 11
- D 00 11 00
Correct Answer: Option A
By De Morgan, "not (≥ 10 and ≤ 20)" equals "< 10 or > 20", so both columns always agree: true for 5 and 25, false for 15.
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!