← Quiz: C Output Questions: all 10 questions
Quiz: C Output Questions · Question 7 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
unsigned int u = 1;
int n = -1;
printf("%s\n", n < u ? "less" : "greater");
return 0;
}
- A.less
- B.greater
- C.Compile error
- D.-1
Answer & explanation
Correct answer: greater
In a mixed comparison, n is converted to unsigned, and -1 becomes a very large number, bigger than 1.
Can you get the rest right without peeking?
Take the timed Quiz: C Output Questions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →