800 views

1 Answer

Best answer
0 votes
0 votes

Here a is 3D array .Suppose base address of a is 1000.

 int *b = a;

b is pointing the address of a  So b will contain 1000.

 int *c = a+1;

Here c containing the address of a+1 i.e. a plus it will skip 1 2D array (20*30*4) so 2400+100 i.e.2500 .

Here Subtracting two Pointers.

Final Result  = (ptr2 - ptr1) / Size of Data Type

So finally c-b =2500-1000=2400/4

600 will be printed.

edited by

Related questions

0 votes
0 votes
2 answers
1
0 votes
0 votes
1 answer
3
Desert_Warrior asked May 16, 2016
3,683 views
#include <stdio.h int main() { struct node { int a; int b; int c; }; struct node s = { 3, 5, 6 }; struct node *pt = &s; printf("%d\n", *((int*)pt+1)); return 0; }
0 votes
0 votes
1 answer
4
Desert_Warrior asked May 16, 2016
526 views
#include<stdio.h int a = 10; int main() { fun(); fun(); return 0; } int fun() { static int a = 1; printf("%d ",a); a++; return 0; }