Question 1
Back to Exercise
Applicants must be 18 to 60 years old. What does the program print for age 70, and why?
#include <stdio.h>
int main(void) {
int age = 70;
if (age >= 18 || age <= 60)
puts("eligible");
else
puts("not eligible");
return 0;
}
- A not eligible
- B eligible – with ||, every age satisfies one side; it must be age >= 18 && age <= 60 Correct
- C Nothing
- D It does not compile
Correct Answer: Option B
70 ≥ 18, so the whole || is true. A range needs both bounds: &&. Compilers often warn that such overlapping comparisons are always true.
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!