ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned char c = 1;
    printf("%d", -c);
}
  1. A. 255
  2. B. 2
  3. C. -1
  4. D. 256

Correct answer: C. -1

c is promoted to int before the unary minus, so -c is -1 and not a wrapped unsigned value.

More C Programming questions

Exams that ask this topic