C program to print the length of a given array
kw.c
#include <stdio.h>
int main()
{
    int arr[] = {1, 2, 3, 4, 5};
    printf("Length of an array is %ld \n", (sizeof(arr) / sizeof(int)));
    return 0;
}
Output
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out Length of an array is 5 kodingwindow@kw:~$
Advertisement