A three-dimensional array in C++ is declared as int A[a][b][c]. Array elements are stored in row-major order and indexing begins from 0. The address of the element A[r][s][t], in terms of the word length w of an integer, is
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. &A[0][0][0] + w(b·c·r + c·s + t)
Explanation
Before A[r] there are r planes of b·c elements; within the plane, s rows of c elements; then t elements. Offset = b·c·r + c·s + t words.More Programming Languages and Computer Graphics questions
- What is the output of the following code?main() { struct s1 { char *z; int i; struct s1 *p; }; static struct s1 a[] = { {"Nagpur", 1, a+1},…
- The Sutherland-Hodgeman method is used on
- What is x in the following program?#include <stdio.h> int main() { typedef int (*(*arrfptr[3])())[10]; arrfptr x; return 0; }
- How will you free the memory allocated by the following program?#include <stdio.h> #include <stdlib.h> #define MAXROW 3 #define MAXCOL 4 in…
- The clipping process in computer graphics is used for
- Consider the rectangle with vertices (0, 0), (0, 2), (3, 0), (3, 2). It is scaled by 2 along the x-axis and 3 along the y-axis. The new coo…