62 votes 62 votes Consider the following C program #include<stdio.h> int main() { static int a[] = {10, 20, 30, 40, 50}; static int *p[] = {a, a+3, a+4, a+1, a+2}; int **ptr = p; ptr++; printf("%d%d", ptr-p, **ptr); } The output of the program is _______. Programming in C gatecse-2015-set3 programming programming-in-c normal numerical-answers pointers + – go_editor asked Feb 15, 2015 go_editor 22.6k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Chhotu commented Oct 25, 2017 reply Follow Share Notice-> In proper answer there is no space between 1 and 40. 6 votes 6 votes Mohd Idrish commented May 20, 2018 reply Follow Share Please answer the following question with the help of diagram *(*(a+3)+2)? 0 votes 0 votes hem chandra joshi commented Jul 6, 2018 reply Follow Share Little modification need in best answer. Address in ptr should use rather than address of ptr? 1 votes 1 votes palashbehra5 commented Nov 15, 2021 reply Follow Share 10 a 20 a+1 30 a+2 40 a+3 50 a+4 …... …... a p a+3 p+1 a+4 p+2 a+1 p+3 a+2 p+4 …... ….. p+1 ptr 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes i have assumed some addresses hope so you will get this sandeepjkh answered Sep 5, 2017 sandeepjkh comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments saipriyab commented Sep 19, 2017 reply Follow Share I think size of the pointer is always 2 bytes .Pointers when we are pointing to the same array then pointer arithmetic is possible which is used to find the number of elements between them.7 (address of (p+1) - address of(p))/(size of each element in the array) 0 votes 0 votes sandeepjkh commented Sep 19, 2017 reply Follow Share No the size of the pointer is 8 bytes for 64 bit computers and for 32 bit computers it is 4 bytes. https://www.quora.com/What-is-the-size-of-a-pointer-in-C 0 votes 0 votes sandeepjkh commented Sep 19, 2017 reply Follow Share size of the pointer depend on compiler in C pointer size iss 2 bytes but generally some compilers take it 4 bytes for 32 bit computers and bytes for 64 bit computers....so in GATE questions take size of pointer as 8 bytes. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes In Layman's terms: ptr-p = location of the block where ptr points - location of the block where p points. ptr and p point to neighbouring cells, hence their difference is 1. You can also see that as subtracting indices, which works in all the cases. ptr points to index 1, and p points to index 0. Now, dereference ptr twice. ptr » a+3 » 40 So, 140. JashanArora answered Oct 5, 2019 JashanArora comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Note: We are assuming the size of Pointer is 2byte that's why (Content of Ptr - Content of p)/2 Krishnakumar Hatele answered Jul 23, 2020 Krishnakumar Hatele comment Share Follow See all 0 reply Please log in or register to add a comment.