ProgrammingHardTCS NQT · Infosys
unsigned char c = 0x0F; printf("%d", (unsigned char)~c); What is printed?
- A. 240
- B. -16
- C. 15
- D. 255
Correct answer: A. 240
~c is an int with low byte 0xF0, and the cast to unsigned char keeps 0xF0, which is 240.
More C Programming questions
- int i = 0; if (0 && i++) ; if (1 || i++) ; printf("%d", i); What is printed?
- unsigned char a = 255; printf("%d", a == -1); What is printed?
- long long x = 1000000LL 1000000; What is x?
- What does printf("%d", sizeof('a') == sizeof(int)) print?
- char words[] = {"one", "two", "three"}; char pp = words + 1; printf("%s", pp + 1); What is printed?
- int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; int p = &a[0][0]; printf("%d", p[4]); What is printed?