C Programming - Pointers - Discussion
Discussion Forum : Pointers - General Questions (Q.No. 6)
6.
What would be the equivalent pointer expression for referring the array element a[i][j][k][l]
Discussion:
70 comments Page 3 of 7.
Pradeep said:
1 decade ago
ptr[0]------>*(ptr+0);
ptr[1]------>*(ptr+1);
Like that:
a[i]---->*(a+i);
a[i][j]---->*(*(a+i)+j);
a[i][j][k]---->*(*(*(a+i)+j)+k);
Now you can understand.
ptr[1]------>*(ptr+1);
Like that:
a[i]---->*(a+i);
a[i][j]---->*(*(a+i)+j);
a[i][j][k]---->*(*(*(a+i)+j)+k);
Now you can understand.
(3)
Prasad said:
10 years ago
If you are passing value in expression through array then to fetch it require pointer and work on Stack mechanism and need to evaluate expression by Post order, or pre order.
Mrutyunjay said:
1 decade ago
We can write a[i] in pointer as *(a + i)
similarly a[i][j] as *(*(a+i)+j)
a[i][j][k] as *(*(*(a+i)+j)+k)
a[i][j][k][l] as *(*(*(*(a+i)+j)+k)+l)
similarly a[i][j] as *(*(a+i)+j)
a[i][j][k] as *(*(*(a+i)+j)+k)
a[i][j][k][l] as *(*(*(*(a+i)+j)+k)+l)
Hiren savalia said:
1 decade ago
Smart 1 ...
in answer we are looking for equivalent POINTER ... and in answer there is only 1 option which has POINTER symbol that is * so select it as answer .... :)
in answer we are looking for equivalent POINTER ... and in answer there is only 1 option which has POINTER symbol that is * so select it as answer .... :)
Harsha said:
1 decade ago
Actually in array concept pointer with create automatically know? Then why should we represent them symbolically? According to this option A is also right na.
Anil kumar Kandula said:
1 decade ago
a[i] = *(a+i)
a[i][j] = *(a[i]+j)
= *(*(a+i)+j)
a[i][j][k]= *(a[i][j]+k)
= *(*(a[i]+j)+k)
= *(*(*(a+i)+j)+k)
a[i][j] = *(a[i]+j)
= *(*(a+i)+j)
a[i][j][k]= *(a[i][j]+k)
= *(*(a[i]+j)+k)
= *(*(*(a+i)+j)+k)
Mamta said:
1 decade ago
One dimensional array represent by*p.
And two dimension with (*(*p)).
Three dimensional with (*(*(*p)))) and so on....
And two dimension with (*(*p)).
Three dimensional with (*(*(*p)))) and so on....
Aswini .g said:
1 decade ago
Here a[0] = *(a+0).
a[0][1] = *(*(a+0)+1)).
Like wise k, l, m, n.
In orderly it follows become the answer.
a[0][1] = *(*(a+0)+1)).
Like wise k, l, m, n.
In orderly it follows become the answer.
Bhava said:
1 decade ago
Since the array element is asked we have to use * operations and 4 times * is because of 4 dimensional array.
Rishabh said:
1 decade ago
An another way to represent pointer as array is ?
ptr[0]------>*(ptr+0);
ptr[1]------>*(ptr+1);
ptr[0]------>*(ptr+0);
ptr[1]------>*(ptr+1);
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers