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