🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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;
}
  1. A.less
  2. B.greater
  3. C.Compile error
  4. 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 →