ProgrammingVery hardProduct company OA
What does z("abcdef") print?
What does z("abcdef") print?
void z(const char *s) {
if (!*s) return;
putchar(*s);
z(s + 2);
if (s[1]) putchar(s[1]);
}- A. acefdb
- B. acebdf
- C. acefbd
- D. abcdef
Correct answer: A. acefdb
Characters at even positions print on the way down: a, c, e. The odd-position partner of each level prints on the way back up, innermost first: f, d, b. So acefdb.
More C Programming questions
- Does this function compile, and what does it do? c struct S { int p; }; void f(const struct S s) { s->p = 5; }
- On a two's-complement machine, what is printed? c int x = 5; printf("%d %d", -~x, ~-x);
- What is printed? c const char s = "ab cd"; printf("%zu", strlen(s));
- On an LP64 system (32-bit int, 64-bit long), what is printed? c printf("%zu %zu", sizeof(2147483647), sizeof(2147483648));
- What is printed? c printf("%d %d", '0', '0');
- What is printed? c printf("%d %d", !!"", !"");