ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
#include <string.h>
int main(void) {
char *names[] = {"x", "yy", "zzz"};
char **pp = names + 1;
printf("%c%d", **pp, (int)strlen(*(pp + 1)));
}- A. y3
- B. y2
- C. x3
- D. z3
Correct answer: A. y3
pp points at names[1], so **pp is the first character of "yy", which is y. *(pp + 1) is "zzz", whose length is 3.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { int a[3] = {1, 2, 3}, b[3] = {4, 5, 6}; int ptr[2] = {a, b}; int (pa)[3] = &b…
- What is printed? c #include <stdio.h> int main(void) { unsigned n = 37; printf("%u", n ^ (n >> 1)); }
- What is printed? c #include <stdio.h> int main(void) { int x = -8; printf("%d", x / 2 + x % 3); }
- What is printed? c #include <stdio.h> int calls = 0; int bs(const int a, int lo, int hi, int k) { calls++; if (lo > hi) return -1; int m =…
- What is printed? Assume short is 2 bytes, int is 4 bytes and both use natural alignment. c #include <stdio.h> struct S { char c; short s…
- How many steps does this Collatz loop take to reach 1 starting from 27? c #include <stdio.h> int main(void) { unsigned n = 27; int steps =…