1,661 views

1 Answer

Best answer
6 votes
6 votes

int a[2][3][4] ;  ===> a is 3 dimensional Array ===> Collection of Two Dimensional Arrays and point to the 0th 2D

 

[4] ---- elements =====> {a,b,c,d}

[3] ---- 1-D Array =====> { {a,b,c,d},{a,b,c,d},{a,b,c,d} }

[2] ---- 2-D Array =====> { { {a,b,c,d},{a,b,c,d},{a,b,c,d} }{ {a,b,c,d},{a,b,c,d},{a,b,c,d} } }

 

1. sizeof(a)

       a ===> 3-D Array = collection of 2D array ====> sizeof(a) = no.of 2D Arrays * size of 2-D Array =  2 * X

 

2. sizeof(*a) 

              *a ===> 2-D Array = converted into collection of 1D array ====> no.of 1-D Arrays * sizeof 1-D array = 3 * Y


3.sizeof(**a) 

      **a ===> 1-D Array = converted into collection of elements ====> sizeof(**a) = no.of elements * size of element = 4* Z
 

4. sizeof(***a)

          ***a ===> element ====> sizeof(***a) = size of element = size of datatype


O/P : -

4) 4 Bytes

3) 4 *  4 Bytes = 16 Bytes

2) 3 * 16 Bytes = 48 Bytes

1) 2 * 48 Bytes = 96 Bytes

selected by

Related questions

1 votes
1 votes
2 answers
1
raushan sah asked May 24, 2018
1,127 views
#include<stdio.h int main() { char *s="\123456789\n"; printf("%d", sizeof(s)); return 0; }why this piece of code gives output $8$please explain. thanx
1 votes
1 votes
1 answer
2
Shiva Sagar Rao asked Feb 16, 2019
642 views
#include <stdio.h int main() { int a = 1; char d[] = "ab"; printf("%d", sizeof(a+d)); return 0; }Explain the Output
1 votes
1 votes
1 answer
3
saumya mishra asked May 15, 2018
1,601 views
#include<stdio.h int main(void) { printf("bytes occupied by '7' = %d\n", sizeof('7')); printf("bytes occupied by 7 = %d\n", sizeof(7)); printf("bytes occupied by 7.0 = %d...
3 votes
3 votes
1 answer
4
Lakshman Bhaiya asked Apr 23, 2018
952 views
Q)What is the output of the following C program fragment?Assume size of an integer is 4 Bytes#include<stdio.h>int main(){int i = 5;int var = sizeof( i++);printf("%d %d",i...