Sunday 28 February 2016

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;

}

No comments:

Post a Comment

Ads Inside Post