703 views
0 0 votes
Caption

@sachinmittal1 sir here answer should be B na because Arr[2] point s to the 0th index of 2nd 1D-array so it means pointing to address of arr[2][0] so address size would be  8.

1 Answer

0 0 votes

 

int arr[3][4];: A 2D array with 3 rows and 4 columns, totaling 12 integers.

int (*p)[12];: A pointer to an array of 12 integers.

p = malloc(sizeof(int) * 24);: Allocates memory for 24 integers (96 bytes, sizeof(int) = 4).


 

sizeof(arr[2]): arr[2] refers to the third row of the 2D array arr, which is an array of 4 integers. sizeof(arr[2]) will be the size of this array, 4 * sizeof(int) = 4 * 4 = 16 bytes.

sizeof(p): p is a pointer, and the size of a pointer is 8 bytes (given sizeof(int *) = 8).

sizeof(*p): *p dereferences the pointer p, which points to an array of 12 integers. sizeof(*p) will be the size of this array, 12 * sizeof(int) = 12 * 4 = 48 bytes.

Position:
Show:

Related questions

3 3 votes
2 2 answers
1.0k
1.0k views
GO Classes asked Apr 30, 2022
1,040 views
If the $32$-bit number given below is stored in little-endian at address $1000,$ what is the value of the byte at address $1002?$ Answer in decimal.$$0001\; 0010 \;0011\;...
4 4 votes
1 1 answer
1.3k
1.3k views
GO Classes asked Apr 30, 2022
1,304 views
#include<stdio.h int test(int *a, int *b) { int c = *a-*b; if (c<0) return 0; else return (1 + test(&c, b)); } void main() { int x = 15; int y = 4; int a = test(&x,&y); p...
5 5 votes
1 answers 1 answer
782
782 views
GO Classes asked Apr 30, 2022
782 views
What will be the output of the following program?It is given that $\textsf{sizeof(int) = 4}$ and $\textsf{sizeof(int *) = 8.}$#include<stdio.h main(){ void p = 1000; int...
3 3 votes
1 1 answer
916
916 views
GO Classes asked Apr 24, 2022
916 views
Consider the following two .c files, which both include the same .h file:When compiled, linked, and executed, the following output results:$x = 1 \; y = 2\; z = 3\; w = 4...