Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

finding second highest number in array

public static int secHigh(int arr[]){
  int firstHigh = 0,secHigh = 0;
  for(int x: arr){
    if(x > firstHigh){
      secHigh = firstHigh;
      firstHigh = x;
    }else if(x > secHigh){
      secHigh = x;
    }
  }
  return secHigh;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #finding #highest #number #array
ADD COMMENT
Topic
Name
6+4 =