Length of array

Q. Write a C program to calculate the length of a given array.


arr[] = {12, 7 , 9 , 4 , 22 , 63 , 74 , 5 , 1 }


Ans.


/*c program for calculate the length of array*/
#include<stdio.h>
int main()
{
 int arr[]={ 12,7,9,4,22,63,74,5,1 };
 int length;
 length = sizeof(arr)/sizeof(int);
 printf("Length of given array = %d",length);
 getch();
 return 0;
}


/*************** Output *****************/
Screen shot for calculate length of array c program




Related programs:

  1. How to create array in C?
  2. Display array in reverse order
  3. Insert new element in array
  4. Delete an exist element in array
  5. Example of array C program

Comments