ProgrammingModerate
In a 2D array with int a[5][5], what is the total number of bytes in one row when int is 4 bytes?
- A. 20
- B. 5
- C. 25
- D. 16
Correct answer: A. 20
A row of int a[5][5] is 5 ints, so sizeof a[0] = 5 x 4 = 20 bytes. 25 is the element count of the whole array, and 5 counts the elements in a row instead of bytes.
More C Programming questions
- What is the most efficient way to check whether an n x n matrix is symmetric in O(n^2)?
- A 3 x 4 matrix holds a[i][j] = i 4 + j + 1. What is the sum of its boundary cells (first and last row, first and last column)?
- The number of ways to tile a 2 x 5 board exactly with 2 x 1 dominoes, counting orientations, is what?
- The length of the longest common subsequence of "ABCBDAB" and "BDCAB" is what?
- What is the Levenshtein edit distance between "kitten" and "sitting" (insert, delete, replace, each cost 1)?
- A 5 x 7 int matrix is stored in row-major order. What is the flat offset of the cell at 1-based row 3, column 4?