Given an array, Print number of elements of the array.
For example:
If the array is
1 2 3 4 5 6
then the number of elements of the array is 6
Implementation:
For example:
If the array is
1 2 3 4 5 6
then the number of elements of the array is 6
Implementation:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(void) {
int *a,n,i;
/* Get the number of elements of the array */
scanf("%d",&n);
/* memory allocation to store n elements */
a=(int*)malloc(sizeof(int)*n);
/* Get the elements of the array */
for(i=0;i<n;i++)
{
scanf("%d",(a+i));
}
/* Print the size of the array or number of elements of the array */
printf("number of elements in the array is %d",n);
return 0;
}