0 votes 0 votes #include<iostream> using namespace std; int main() { int a[] = {10,20,30,40,50}; cout<<(*(&a+1)-a); return 0; } how th o/p is 5 ?? Programming in C programming-in-c numerical-answers programming output + – vijju532 asked Jul 18, 2018 vijju532 351 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes let us consider array A[] stored at starting address 1000 and taking int size as 2 bytes. So when you simply say A it gives you base address of array i.e here 1000 Now your statement as wriiten in cout....... (&A+1 ) will skip whole 1D array means here all 5 elements would be skipped i.e it will be 1000+10=1010, now further we are subtracting A from this means (1010-1000)/2=5 Note: whenever you subtract two addresses it gives number of element between them, so you need to divde by size of each element i.e 2 here. Shubham Shukla 6 answered Jul 18, 2018 • selected Jul 18, 2018 by junaid ahmad Shubham Shukla 6 comment Share Follow See 1 comment See all 1 1 comment reply vijju532 commented Jul 18, 2018 reply Follow Share can u provide some links to cover this concept ? 0 votes 0 votes Please log in or register to add a comment.
3 votes 3 votes ............. abhishekmehta4u answered Jul 18, 2018 abhishekmehta4u comment Share Follow See 1 comment See all 1 1 comment reply Gurdeep Saini commented Jan 1, 2019 reply Follow Share *(&a+1) what is significance of dereference(*) here ?? 0 votes 0 votes Please log in or register to add a comment.