Want this question answered?
find even number in array
(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).
The simplest way is usually to iterate through an array using a loop and store either the index or the value of the highest number you find. For example: int findLargestIndex(int *array, int arraysize) { int largestIndex = 0; for(int i = 0; i < arraysize; i++) { if(array[i] > array[largestIndex]) largestIndex = i; } return largestIndex; }
Basically, &array[i]; That is, the memory location for an array object with index i. Or, you can do: (array + i);
1010
array.length will return the number of elements in array.
Traverse the array from index 0 until you find the number. Return the index of that number.
find even number in array
The numbers of rows and columns in a rectangular array form a factor pair for that number.
(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).
You can find the number of elements and free elements in a pointer array by iterating through the array and counting the number of elements that are null versus the number that are non-null. Of course, this technique's success depends on proper initialization of each element, i.e. when first created or when deleted, it must be set to null.
For instance, you have array of type int with a name myArray, and you do not know size of the array. You can use following statement to get it:int arraySize = myArray/myArray[0];arraySize gives you number of elements in myArray.
The simplest way is usually to iterate through an array using a loop and store either the index or the value of the highest number you find. For example: int findLargestIndex(int *array, int arraysize) { int largestIndex = 0; for(int i = 0; i < arraysize; i++) { if(array[i] > array[largestIndex]) largestIndex = i; } return largestIndex; }
The number of elements in a 5 x 46 array = 5*46.
Basically, &array[i]; That is, the memory location for an array object with index i. Or, you can do: (array + i);
1010
by using index position we can find the particular element in array.