in Programming
103 views
0 votes
0 votes

#include <stdio.h>

int main(){

int a[] = {5,3,7,2,4};

int *p = &a[3];

p -= *p;

printf("%d ",*p);

return 0;

}

 

output is 3.

Why 2 * sizeof(int) is doene.????

in Programming
103 views

1 comment

@Abhrajyoti00 @gatecse 

your opinion on this question.

 

0
0

1 Answer

2 votes
2 votes
Best answer
because it is an integer array and by the command p -= p*(p* = derefrenced value of pointer p = 2) which is equal to p = p – 2 , means we are decreasing the address of pointer by 2*4 byte i.e. 8 byte
selected by

Related questions