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 in C, you can use it on any type of array. For more topics, refer to the C programs article.

#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

Also Read