/ Published in: C++
Write function "get_min_range" which returns the subscript of the smallest value in a portion of an array containing type int values. It has three arguments: an array, the first subscript in the subarray, and the last subscript in the subarray.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
int get_min_range(int array[], int firstSubscript, int lastSubscript) { int smallestValue = array[firstSubscript]; int smalledIndex = firstSubscript; for (int i = firstSubscript; i <= lastSubscript; i++) { if (array[firstSubscript] < smallestValue) { smallestValue = array[firstSubscript]; smalledIndex = firstSubscript; } } return smalledIndex; }