All mock tests are FREE till 31 December — register to save your progress
Unit 3 · Programming Languages and Computer Graphics Paper 2 CS · December 2022 (Shift 1)

Given int arr[3][4][2] = {{{2,4},{7,8},{3,4},{5,6}}, {{7,6},{3,4},{5,3},{2,3}}, {{8,9},{7,2},{3,4},{5,1}}}; which of the following can be used to refer to the element 1?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. *(*(*(arr + 2) + 3) + 1)

Explanation

The value 1 is arr[2][3][1], which in pointer form is *(*(*(arr + 2) + 3) + 1). arr[3][4][2] and arr[2][3][2] are out of bounds.

More Programming Languages and Computer Graphics questions