One c language student requested to write a program to find the size of an array so that I am writing this tutorial. In this program, we will share a c program which will calculate the size of an array.
In this program, we have used sizeof() function to calculate the size of an array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stdio.h> int arr[8]= { 1, 2, 3, 4, 5, 6 }; int main() { int length; length = sizeof(arr)/sizeof(int); printf("The length of Array is %d", length); return 0; } |
The length of Array is 6
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: array in c, array in c language, array size, c program, c program examples with output, c programs, c programs with solutions, list of important c programs, what is array in c