ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
char *w[] = {"ab", "cd", "ef"};
char **p = w + 2;
printf("%c%c", (*p)[0], p[-1][1]);
}- A. ef
- B. ed
- C. cd
- D. fe
Correct answer: B. ed
p points at w[2], so (*p)[0] is e, and p[-1] is w[1] = "cd", whose second character is d. Mixing up the indexes gives fe or ef.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { unsigned v = 0x01020304u, total = 0; for (int i = 0; i < 4; i++) { unsigned b = (v…
- What is printed? Compute the XOR of all integers from 1 to 1000 with this program. c #include <stdio.h> int main(void) { unsigned x = 0…
- How many monotone lattice paths go from the top-left corner to the bottom-right corner of a 4 by 4 grid of cells (moves only right or…
- How many iterations does this loop run? c #include <stdio.h> int main(void) { int c = 0; for (int i = 10; i >= 0; i -= 3) c++…
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (int)'x41' + '101'); }
- What is printed? Assume int is 32 bits. c #include <stdio.h> struct B { unsigned a : 3; }; int main(void) { struct B s; s.a = 13…