Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 range

Explanation / 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||lower
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote