896 views
0 0 votes

answer is given 20,60

but my answer is 20,10 

in solution they given that  (&arr+1= base address of arr+ 1*6) 

how it possible . Is it true or wrong

3 Answers

1 1 vote
20, 60 is the correct answer.

Below is the output of above code: (I have added extra statements to print for your clarity)

 

20 60
ptr: 6422040
arr: 6422034
ptr-1: 6422039
arr+1: 6422035
(&arr + 1): 6422040

 

In this we are assigning &arr+1 to ptr, not just arr+1, &arr+1 will return immediate next address after the end of the array. That's why ptr contains the value of the next location after the array.
You got under the impression that ptr was pointing to 20, but actually, it is pointing to memory location just after 60.

Hope this helps.
0 0 votes
arr points to first element of array and &arr points to whole array so on increment arr+1 points to next memory element while &arr+1 points to memory next location which is out of array

and so ptr-1 points last element
Position:
Show:

Related questions

0 0 votes
2 2 answers
1.6k
1.6k views
Na462 asked Jan 16, 2019
1,638 views
void PrintValue(int n) { if (n < 0) return; else { printf(n); printValue( n); printValue(n ); printf(n); } }Output for Print(5) ?
0 0 votes
1 1 answer
850
850 views
Jaggi asked Jan 30, 2019
850 views
100 stations on a pure Aloha network share a 1 MBPS channel. if frames are 1000 bits long, find the throughput if each station is sending 10 frames per second
2 2 votes
2 2 answers
1.1k
1.1k views
Naveen Muralidhar asked Jan 20, 2019
1,126 views
I thought 2600 cause after 34, it takes one RTT and size becomes 36 before sending the 14th segment(i.e., segment with window size = 36KB). Questions based on this are c...
0 0 votes
0 0 answers
940
940 views
balchandar reddy san asked Jan 17, 2019
940 views
A grammar that has no epsilon productions and also free from unit productions. The maximum number of reduce moves that can be taken during bottom-up evaluation of 25 toke...