Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to get largest and second largest in an array of integer.

$
0
0
I just want to ask what should be the way to do it, not asking for code.
So currently, I declare 2 variables: largest and second largest.
I go thru the array of integer, and state:
if (array[i] > largest){
largest = *array[i];} else if (array[i] > second largest) { second largest = *array[i]}; 


Please correct me

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>