Home > Algorithms > Find largest number in an Array. Also find the index where it is there in array

Find largest number in an Array. Also find the index where it is there in array

July 7, 2012

private int findLargest(int[] integers) {

int i;
int index =0;
int largest = integers[0];

for(i=0;i
if(largest < integers[i]) {
largest = integers[i];
index = i;
}
}
return index;
}
Advertisements
Categories: Algorithms
%d bloggers like this: