C program to print the length of a given array
codeaft.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
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out Length of an array is 5 codeaft@codeaft:~$
Comments and Reactions