The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
145 views
#include <stdio.h>
int main()
{
    int a[] = {50, 60, 10, 30, 40, 20 };
    int *b[] = {a+3, a+4, a, a+2, a+1, a+5 };
    int **c = b;
    c++;
    printf("%u, %u, %u\n", c-b, *c - a, **c);
    return 0;
}
asked in Programming by Boss (6.6k points) | 145 views
Answer : 1,4,40

@Prashant. I am not getting this,

when we do, c-b why we got 1 as answer, likewise when we do *c-a why we got 4 as answer ?

Here i modified to programme to see the address, i think c-b should be 8 and *c-a should be 16. Where i am going wrong ?

3347544000 is nothing the base address of the array b.

3347544008 is nothing the 2nd element address of the array b.  which is contain by c after c++.

3347544008 - 3347544000 = 8 but we know pointer take 8 byte here . so divide by size of pointer is needed. so 8/8= 1

1 Answer

+3 votes
Best answer

Output will be 

1,4,40

answered by Junior (675 points)
selected by

Related questions

0 votes
1 answer
1
0 votes
0 answers
2
+1 vote
1 answer
3


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

29,006 questions
36,838 answers
91,329 comments
34,718 users