To find an array's size at runtime, divide total bytes by element bytes. The expression sizeof(arr) / sizeof(arr[0]) gives element count. sizeof(arr) returns total memory, sizeof(arr[0]) returns one element's size.
This works because arrays store elements contiguously. If int is 4 bytes and your array uses 20 bytes, you have 20/4 = 5 elements. Division calculates count from byte measurements. Warning: this only works with actual arrays, not pointers.
When passed to a function, arrays decay to pointers, and sizeof returns pointer size (8 bytes) instead of array size.