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 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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.