1 votes 1 votes #include<stdio.h> main() { int a[][3] = {1, 2, 3, 4, 5, 6}; int (*ptr)[3] = a; printf("%d %d ", (*ptr)[1], (*ptr)[2]); ++ptr; printf("%d %d\n", (*ptr)[1], (*ptr)[2]); return 0; } explain this program? Siddharth Bhardawaj asked May 2, 2018 Siddharth Bhardawaj 279 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes ${\color{Red} {int (*ptr)[3]} } \rightarrow$ This is a pointer to an array of $3 \ integers$ ${\color{Blue} {int (*ptr)[3] = a}} \rightarrow$ it stores address of $a$ . ${\color{Blue} {(*ptr)[1] }} \rightarrow$ it is $a[0][1]$ which is $2$ ${\color{Blue} {(*ptr)[2] }} \rightarrow$ it is $a[0][2]$ which is $3$ ${\color{Blue} {(++ptr) }} \rightarrow$it is increased .it accesses to $2^{nd}$ row of the array ${\color{Blue} {(*ptr)[1] }} \rightarrow$ it is $a[1][1]$ which is $5$ ${\color{Blue} {(*ptr)[2] }} \rightarrow$ it is $a[1][2]$ which is $6$ pankaj_vir answered May 2, 2018 selected May 2, 2018 by srestha pankaj_vir comment Share Follow See all 0 reply Please log in or register to add a comment.