ProgrammingHardProduct company OA
With 4-byte int, what is printed?
With 4-byte int, what is printed?
int x = 7;
printf("%zu %zu", sizeof (int) * 3, sizeof x + 1);- A. 4 5
- B. 4 8
- C. 12 5
- D. 12 4
Correct answer: C. 12 5
sizeof (int) is a complete operand, so the expression is (sizeof(int)) * 3 = 12. sizeof is a unary operator binding tighter than +, so sizeof x + 1 = 4 + 1 = 5, not sizeof(x + 1).
More C Programming questions
- What is printed? c char s[8] = {'a', 'b'}; printf("%zu %zu %d", strlen(s), sizeof s, s[7]);
- What does r(3) print, and how many digits would r(6) print? c void r(int n) { if (n == 0) return; r(n - 1); printf("%d", n); r(n - 1); }
- What is printed? c const char s = "abcdefgh"; const char p = s + 2, q = strchr(s, 'g'); printf("%td %c %s", q - p, (p + (q - p) / 2), q);
- Given int f(int); and int (fp)(int) = f; which of these calls are valid? (i) fp(2) (ii) (fp)(2) (iii) (fp)(2) (iv) (&fp)(2)
- What is printed? c union U { int i; float f; } u = {3.9}; printf("%d", u.i);
- What is printed? c int i = 0, c = 0; while (i < 10 && ++c && i++ % 3 != 2); printf("%d %d", i, c);