ProgrammingModerateTCS NQT · Infosys
printf("%d", 0x7FFFFFFF == 2147483647); What is printed?
- A. 0
- B. 1
- C. 2147483647
- D. compile error
Correct answer: B. 1
0x7FFFFFFF is the hexadecimal form of 2147483647, so the two constants are equal and the comparison yields 1.
More C Programming questions
- unsigned char c = 0xFF; unsigned int u = c << 8 | c; printf("%X", u); What is printed?
- static int total = 0; int add(int n) { static int t = 0; t += n; return t; } Calls add(3), add(4) and add(5) in that order. What does the…
- int r = 0; switch (2) { case 1: r += 1; case 2: r += 10; case 3: r += 100; break; default: r += 1000; } What is r?
- for (int i = 0, j = 10; i < j; i += 3, j -= 3) count++; How many times does the body run?
- int n = 5; int r = n++ 2; What are the final values of r and n?
- Adding two non-negative ints a and b without +, a loop repeats a = a ^ b and b = (old a & old b) << 1 until b is 0. Starting with a = 5…