ProgrammingVery hardProduct company OA
What is printed?
What is printed?
#include <limits.h>
printf("%u %d", UINT_MAX + 1u, UINT_MAX == -1);- A. 0 1
- B. 0 0
- C. 4294967296 0
- D. Undefined: the addition overflows
Correct answer: A. 0 1
Unsigned arithmetic wraps modulo 2^N by definition, so UINT_MAX + 1u is 0, never undefined. In UINT_MAX == -1 the int −1 is converted to unsigned int, which gives UINT_MAX, so the comparison is true.
More C Programming questions
- What is printed? c int ways(int a, int n, int t) { if (t == 0) return 1; if (n == 0 || t < 0) return 0; return ways(a + 1, n - 1, t…
- What value does this call to printf return? c printf("%5.1f|%-5d|", 3.14159, 42);
- What is printed? c const char w[] = {"red", "green", "blue", "cyan"}; const char p[] = {w + 2, w, w + 3, w + 1}; const char q = p…
- What is printed? c int m(int n) { return n > 100 ? n - 10 : m(m(n + 11)); } int main(void) { printf("%d %d", m(50), m(105)); }
- What is printed? c int h(unsigned a, unsigned b) { int c = 0; for (unsigned x = a ^ b; x; x >>= 1) c += x & 1; return c; } int main(void)…
- What is printed? c int a[] = {10, 20, 30, 40, 50}; int p = &a[3]; printf("%d %d %d", p[-2], -1[p], (p - 1)[-1]);