A basic c++ program using only the library that creates A smallestElementIndex f
ID: 3659535 • Letter: A
Question
A basic c++ program using only the library that creates A smallestElementIndex function that takes in an entire integer array, a range (normally represented by two integers: the lower and the upper bound of the indexes), and locates the element within that range that has the smallest value, and returns the index of that smallest element within that rangeExplanation / Answer
#include using namespace std; int smallestElementIndex (int arr[],int lowerBound,int upperBound){//assuming upperBound is less than arr size int smallest; //corrects bounds if reversed if(lowerBound>upperBound){ return smallestElementIdex(arr[],upperBound,lowerBound); } smallest=lowerBound; for(int i=lowerBound+1;iarr[i]) smallest=i; }//end for return smallest; } int main(){ int arr[10]; int upper,lower,smallest; //load array for(int i=0;i9||lowerRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.