ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned char c = 1;
printf("%d", -c);
}- A. 255
- B. 2
- C. -1
- 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
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { char s[] = "hello"; char p = strchr(s, 'l'); printf("%ld"…
- How many moves does this recursive Towers of Hanoi program make for 4 disks? Compute with the program. c #include <stdio.h> int moves = 0…
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x96; uint8t r = (uint8t)((x << 3) | (x >> 5))…
- What is printed? Assume signed char is 8 bits, two's complement. c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { long long x = (const long long )a, y =…
- What is printed? c #include <stdio.h> int calls = 0; int g(int a, int b) { calls++; return b ? g(b, a % b) : a; } int main(void) { int r =…