in Programming in C
446 views
0 votes
0 votes

what is the output?

in Programming in C
by
446 views

2 Comments

Maybe 14.
0
0
14 is given as the answer.....can you explain how you trace out the code?
0
0

1 Answer

0 votes
0 votes

ANS : 14 

2 Comments

how pointer is pointing to 1,2,5,6....not getting it
0
0
p = arr // p is pointing to first 2d array

m = 0 .....ptr = p + m = p ;  ptr is pointing to the first element of first 2d array

ptr = ptr + row  // row = 0

ptr = ptr + col(0)

sum = sum + *(ptr + col)  // here differencing is done *(ptr+ 0) // will give 1

similarly *(ptr+col(1))  // will give 2

and come out of  innermost for loop. Note that row +=2 ....thus row becomes 2  and it will come out of second for loop.

In the outermost loop again ptr = p + m(1)    // ie ptr will point to first element of second 2d array and same procedure will be repeated to give 5 and 6.

I have assumed Row wise order.
0
0

Related questions

0 votes
0 votes
1 answer
1
himgta asked in Programming in C Sep 12, 2018
390 views
himgta asked in Programming in C Sep 12, 2018
by himgta
390 views
1 vote
1 vote
1 answer
2
himgta asked in Programming in C Apr 13, 2018
323 views
himgta asked in Programming in C Apr 13, 2018
by himgta
323 views