3 votes 3 votes Main () { int a [3] [4] = $\begin{pmatrix} 1&2&3&4 \\ 5&6&7&8 \\ 9&10&11&12 \\ \end{pmatrix}$ printf ("\n% u% u% u", a[0]+1, * (a[0] + 1), *(*(a + 0)+1)); } What is the output of the above program? Assume array begin at address 10. Programming in C array pointers + – sabir asked Nov 24, 2015 • edited Jan 31, 2016 by makhdoom ghaya sabir 904 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Hira Thakur commented Nov 25, 2015 reply Follow Share when i excute 3rd statement of printf then what is the output??? anyone explain in detail... 0 votes 0 votes sabir commented Nov 26, 2015 reply Follow Share a+0 means we are skipping 0 rows. Means we are not skipping any thing. (a+0)+1 means we are skipping only 1element in row 1, so we move to 2. It is same as statement 2 but different representation. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes 12, 2 , 2 first will print address of 1st row 2st column element which is 10 +2= 12 second will print value at that address i.e. 2 Third is same as second i.e. different expression = 2 Prashant. answered Nov 24, 2015 Prashant. comment Share Follow See 1 comment See all 1 1 comment reply ManojK commented Nov 24, 2015 i edited by ManojK Nov 24, 2015 reply Follow Share 12 or 14 sorry depends on size // 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes a[0]+1 Given code will skip 1 element of 2d array so it will print address of second which is 14.(Given a=10). a[0]+1 Will print value at the address (a[0]+1) which 2. *(a[0]+1)=*(*(a+0)+1) Same as above Will print value at the address (a[0]+1) which 2. SO output:14,2,2 ManojK answered Nov 24, 2015 ManojK comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments ManojK commented Nov 24, 2015 reply Follow Share Yes a+1 mean 1 row will skipped *a+1 after selecting row 1 element will be skip 1 votes 1 votes sabir commented Nov 24, 2015 reply Follow Share Thx... So I think it should be 12 not 14 ...as it moving to 2 and type unsigned int, which will increment the address by 2....if we consider row major order. And there is nothing mention about ordering, so how to figure out which order we should consider. 0 votes 0 votes ManojK commented Nov 24, 2015 reply Follow Share 12 or 14 depends on size of int. by default row major otherwise it will be mentioned. 0 votes 0 votes Please log in or register to add a comment.