Couldn't understand working of Sizeof in array

int a[ ]={1,2,3,4}
int n= sizeof(a) / sizeof(int)

here i cannot understand the logic of how sizeof() works
and what the sizeof() calculates?

Hello @aggarwal.naman21,

sizeof determines the size, in bytes, of a variable or data type,
sizeof(a) = 4*4 = 16
sizeof(int) = 4

n = 16/4 = 4

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like