ProgrammingHard
char g[3][4] = {"abc", "de", "f"}; What is the value of g[1][2] when printed with %d?
- A. 101
- B. 0
- C. 32
- D. -1
Correct answer: B. 0
"de" fills g[1][0] and g[1][1] and the terminator takes g[1][2]. The rest of the row is zero-filled, so the printed value is 0.
More C Programming questions
- int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; How many monotone paths (moves right or down) are there from m[0][0] to m[2][2]?
- For the grid w = {{1,3,1},{1,5,1},{4,2,1}}, what is the minimum sum of a path from top-left to bottom-right moving only right or down?
- An n x n matrix of ints is read row by row. Which code reads it correctly into int a[n][n] when n is a run-time value?
- A 1000 x 1000 grid of cells must be checked for the connected component containing a start cell. Which method is correct and fast enough?
- int a[3][3] = {{2,7,6},{9,5,1},{4,3,8}}; Are all of the row sums, column sums and both diagonal sums equal to 15?
- Row-major storage of int a[4][5] means a[i][j] is at flat index i 5 + j. What flat index holds a[3][2]?