how to find no. of elements in an integer array of given size

I have made an integer array of size 1000 and inserted some elements in it .Now I want to find the number of elements inserted.What can I do?

It depends how the elements have been inserted. If the elements are inserted one after the other in consecutive indexes then the best thing is to keep a counter which points out the location of the currently last element and increment it every time a new element is added. On the other hand if the array already has some predefined value say 0 and you have inserted some other numbers in it(non zero numbers) then you can only go for an O(n) approach to count the number of non zero in the array.

// c code from payal
void main()
int A[1000]={10,20,34,25},i=0,count=0;
printf(“array size is:1000”);
printf(“total elements present in array at present are:\n”);
while(A[i]!=000) //000 for cheking blank space ASCII value of blank space is 000

check this…