S sonali @sonalirangwani added a Question 2 Feb 2017 For Loop how to solve this? 4Comments thumbs up down up1 liked Ashish Kumar Goyal @dashish 2 Feb 2017 03:49 pm it will be 30. up2 liked Log in or register to post comments S sonali @sonalirangwani 2 Feb 2017 03:57 pm please explain me!! 30 is right answer up0 like Log in or register to post comments Ashish Kumar Goyal @dashish 2 Feb 2017 04:26 pm Nothing mentioned so by default take row major order. *(p+20*j+i) is same as accessing p[j][i]. so p[6][10]=306 and p[6][9]=276.. Subtract and u will get 30. up2 liked Log in or register to post comments Ashish Kumar Goyal @dashish 3 Feb 2017 09:54 am @sonalirangwani @sumitverma Though answer came to be correct but i was wrong.. Notice A[20][30]..... therefore, *(p+20*j+i) will not equal p[j][i]. here, we will check for what vaue of i and j, we will point to A[6][10] and A[6][9].. A[6][10] = *(p + 30*6 + 10)= *(p + 180 + 10) = *(p + 20*9 + 10) => i.e., for j=9 and i=10, A[6][10] = 30*10 + 9 =309 Similarly, A[6][9] => for j=9 and i=9. A[6][9] = 30*9 + 9 = 279. hence, 309-279 = 30. up2 liked Log in or register to post comments

it will be 30.

please explain me!! 30 is right answer

Nothing mentioned so by default take row major order.

*(p+20*j+i) is same as accessing p[

j][i].so

p[6][10]=306andp[6][9]=276.. Subtract and u will get30.@sonalirangwani @sumitverma

Though answer came to be correct but i was wrong..

Notice A[20][30].....therefore, *(p+20*j+i) willnot equalp[j][i].here, we will check for what vaue of i and j, we will point to A[6][10] and A[6][9]..

A[6][10]= *(p + 30*6 + 10)= *(p + 180 + 10) = *(p + 20*9 + 10) => i.e.,for j=9 and i=10,A[6][10] = 30*10 + 9 =309Similarly,

A[6][9] =>forj=9 and i=9.A[6][9] = 30*9 + 9 =279.hence, 309-279 =

30.