This post helps to find the size of the array using the C programming language.
C Program to find the size of the array
#include <stdio.h> int main() { int array[5]= { 1, 2, 3, 4, 5 }; int size; size = sizeof(array)/sizeof(int); //Print size of Array printf("The Size of Array is %d", size); return 0; }
Output
Explanation
In this program we get to find the size of the array by assigning the value for array and using a variable.
We calculate the size of the array with the use of sizeof function.
int array[5]= { 1, 2, 3, 4, 5 }; int size; size = sizeof(array)/sizeof(int);
Now we progress to displaying the desired result.
//Print size of Array printf("The Size of Array is %d", size);
We now get the fancied output.
1 Comment