ProgrammingModerate
char *grid[2] = {"ab", "cd"}; printf("%c", grid[1][0]); What is printed?
- A. d
- B. c
- C. a
- D. b
Correct answer: B. c
grid[1] is the second pointer, to "cd", and [0] picks its first character, 'c'. Swapping the indices gives grid[0][1] = 'b', and 'd' is grid[1][1].
More C Programming questions
- struct S { int a; char c; } arr[2] = {{1}}; printf("%d", arr[1].a); What is printed?
- int a[5] = {[2] = 7, 9}; printf("%d", a[3]); What is printed?
- char s = "hi"; s++; printf("%s", s); What is printed?
- int x = 1; { int x = 2; printf("%d", x); } printf("%d", x); What is printed?
- printf("%d", (int)'A' + 'x01'); What is printed?
- for (char c = 'z'; c > 'w'; c--) putchar(c); What is printed?