In C, you can determine the size of an array by using the sizeof
operator. To calculate the number of elements in a statically declared array, you divide the total size of the array by the size of one element. Here’s an example:
In this code, sizeof(arr)
gives the total byte size of the array, while sizeof(arr[0])
gives the size of one element. The result is the number of elements in the array.