ProgrammingVery hardProduct company OA
Assume 4-byte int. What is printed?
Assume 4-byte int. What is printed?
printf("%d %d", sizeof(int) * -1 < 0, (int)sizeof(int) * -1 < 0);- A. 0 1
- B. 0 0
- C. 1 1
- D. 1 0
Correct answer: A. 0 1
sizeof yields an unsigned size_t, so −1 is converted to size_t and the product is a huge positive number, never below 0. The cast binds tighter than *, so (int)sizeof(int) is the int 4 and 4 × −1 = −4 < 0 is true.
More C Programming questions
- What is printed? c Bool b = 0.5; printf("%d %d", b + 2, (Bool)256);
- What is printed? c int c = 0; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { if (j == 1) break; c++; } printf("%d", c);
- With 4-byte int, what is printed? c int a[4] = {1, 2, 3, 4}; char c = (char )a; int p = (int )(c + 8); printf("%d %td", p, p - a);
- What does Staticassert(sizeof(long) >= 8, "need 64-bit long"); do in C11?
- What is printed? c int i = 0, s = 0; do { if (++i == 3) continue; if (i == 5) break; s += i; } while (i < 10); printf("%d %d", s, i);
- What is printed? c struct N { int v; struct N nx; }; void del(struct N h, int x) { while (h) { if ((h)->v == x) h = (h)->nx; else h =…