ProgrammingHardProduct company OA
What is printed?
What is printed?
printf("%zu %zu", sizeof("ab" "cd"), strlen("ab\0cd"));- A. 6 2
- B. 5 2
- C. 5 5
- D. 6 5
Correct answer: B. 5 2
Adjacent string literals are merged into one, "abcd", which needs 5 bytes with its '\0'. strlen stops at the first '\0', which the escape puts after "ab", so it returns 2. '6' counts a terminator for each piece.
More C Programming questions
- What is printed? c int n = printf("%d", printf("%s", "abc")); printf(" %d", n);
- What is printed? c int f(int n, int b) { return n < b ? 1 : 1 + f(n / b, b); } int main(void) { printf("%d %d %d", f(1000, 2), f(1000…
- What is printed? c const char s = "education"; int v = 0, o = 0; for (; s; s++) switch (s) { case 'a': case 'e': case 'i': case 'o': case…
- Which of these functions return a pointer that is still valid to read after the function returns? c char f1(void) { char s[] = "hi"…
- Assume 32-bit unsigned int. What is printed? c unsigned int x = 65536; printf("%u %u", x x, x (x - 1) / 2);
- What is printed? c int i = 0; while (i++ < 5); printf("%d", i);