C Program to find the Number of Elements in an Array

Write a C program to find the number of elements in an array with an example. In C language, we can use the sizeof operator to get the total number of array items. Though we apply this only on integer array, you can use it on any array type of C.

#include <stdio.h>

int main()
{
    int arr[] = {10, 20, 30, 40, 50, 60};
	
	int nums = sizeof(arr) / sizeof(arr[0]);
    
    printf("Total Number of Array Items = %d\n", nums);

    return 0;
}
C Program to find the Number of Elements in an Array