Question 8476 – Arrays
April 19, 2024
Computer-Networks
April 19, 2024
Question 8476 – Arrays
April 19, 2024
Computer-Networks
April 19, 2024

Arrays

Question 13
If p is a two-dimensional array having 10 and 20 columns, then which of the following cannot be used to access the element in row 2 and column 5?
A
P[2][5]
B
*(*(P+2)+5)
C
*(P[2]+5)
D
*(P+2+5)
Question 13 Explanation: 
Option (A):
P[2][5] represents the element present in column five of row two. So it can be used to access the required given element in question.

Option (B):
*(*(P+2)+5)
*(P+2) → will lead to enter row two.
(*(P+2)+5) will give address of element present at fifth column of row 2.
→ *(*(P+2)+5) will return element present at fifth column of row 2.
Hence option (B) is Correct.

Option (C): *(P[2]+5)
P[2] → will give starting address of row 2
P[2]+5 → will give address of element present at 5th column of row 2.
*(P[2]+5) → will return the element present at 5th column of row 2.
Hence it is correct option.

Option (D): *(P+2+7)
= (P+7)
*(P+7) will return starting address of 7th row.
→ Hence it is not the correct answer.

Correct Answer: D
Question 13 Explanation: 
Option (A):
P[2][5] represents the element present in column five of row two. So it can be used to access the required given element in question.

Option (B):
*(*(P+2)+5)
*(P+2) → will lead to enter row two.
(*(P+2)+5) will give address of element present at fifth column of row 2.
→ *(*(P+2)+5) will return element present at fifth column of row 2.
Hence option (B) is Correct.

Option (C): *(P[2]+5)
P[2] → will give starting address of row 2
P[2]+5 → will give address of element present at 5th column of row 2.
*(P[2]+5) → will return the element present at 5th column of row 2.
Hence it is correct option.

Option (D): *(P+2+7)
= (P+7)
*(P+7) will return starting address of 7th row.
→ Hence it is not the correct answer.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!