ProgrammingModerate
char g[2][3] = {"xy", "z"}; printf("%c", g[0][1]); What is printed?
- A. y
- B. x
- C. z
- D. 0
Correct answer: A. y
"xy" fills g[0] as 'x', 'y', '\0', so g[0][1] is 'y'. 'z' belongs to g[1], and 'x' is g[0][0], the usual off-by-one slip.
More C Programming questions
- int a[3][4] = {0}; a[2][3] = 9; int p = &a[0][0]; printf("%d", p[11]); What is printed?
- char s[] = "atb"; printf("%zu", strlen(s)); What is printed?
- char s[] = "x0y"; printf("%s", s); What is printed?
- char s[5] = "abc"; printf("%d", s[4]); What is printed?
- printf("%zu", strlen("a b c")); What is printed?
- char buf[16]; sprintf(buf, "%d-%d", 1, 22); printf("%zu", strlen(buf)); What is printed?