I can find the smallest number in an array:
...but how can I get the smallest 5 numbers in an array? I'm struggling with this. Any help? Thanks.Code:#include <stdio.h>
int main(){
int array[10] = {22,14,3,6,2,37,19,24,9,12};
int i;
int smallest = array[0];
for(i = 0; i < 10; i++){
if(array[i] < smallest){
smallest = array[i];
}
}
printf("%d ", smallest);
}