Question discussion

What is the output of the following C program?#include int main() { unsigned char x = 200; x += 100; printf("%d %d", x, (char)x == 44); ret…

1989Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    unsigned char x = 200;
    x += 100;
    printf("%d %d", x, (char)x == 44);
    return 0;
}
  • A44 0
  • B300 1
  • C44 1
  • D300 0
Correct answer: C

Explanation

An unsigned char holds values 0 to 255, so 300 wraps around to 300 − 256 = 44, and the comparison with 44 is true (1).

Discussion 0

Nobody has replied yet. Start the discussion!