Choose a correct C statement to choose number 26 in the array,
int arr[3][3] = { {11,22,44}, {33,44, 26}, {55,66, 78} };
a. arr[1][3]
b. arr[3][2]
c. arr[1][2]
d. All of the above
Answers
Choose a correct C statement to choose number 26 in the array,
int arr[3][3] = { {11,22,44}, {33,44, 26}, {55,66, 78} };
a. arr[1][3]
b. arr[3][2]
c. arr[1][2]
d. All of the above
c. arr[1][2]
Declares arr as two - dimensional array , which contains 3 row and 3 columns and can be shown as follow :
- C stands for column
- R stands for rows
⠀⠀⠀⠀⠀C 0 ⠀⠀⠀C 1⠀⠀⠀⠀C2
R 0⠀| ⠀[0][0]⠀|⠀[0][1]⠀|⠀[0][2]⠀|
R 1⠀|⠀[1] [0]⠀|⠀[1] [1]⠀|⠀[1] [2]⠀ |
R 2⠀|⠀[2][0]⠀|⠀[2][1]⠀|⠀[2][2]⠀|
⠀
Let's initialise a our two dimensional array
⠀⠀⠀⠀⠀C 0 ⠀C 1⠀⠀C2
R 0⠀| ⠀11⠀|⠀22⠀|⠀44⠀|
R 1⠀|⠀33⠀|⠀44⠀|⠀26⠀ |
R 2⠀|⠀55⠀|⠀66⠀|⠀78⠀|
⠀
now we can see that
- [0][0] = 11
- [0][1] = 22
- [0][2] = 44
- [1] [0] = 33
- [1] [1] = 44
- [1] [2] = 26
- [2][0] = 55
- [2][1] = 66
- [2][2] = 78
⠀
In the question we can see that we need to choose the correct C statement which is showing us number 26 and the C statement which is showing as 26 is [1] [2] = 26 ; hence the correct option is option c.
Answer:
option c is the correct answer.
c.arr[1][2]
Explanation:
because 26 no. arrray lies in arr[1][2]
and in arr[1][3] and arr[3][2] dont exist