//function prototypes (Youshould put necessary function prototypes here.) int Fi
ID: 3618009 • Letter: #
Question
//function prototypes (Youshould put necessary function prototypes here.)
int FindMin(const int anArray[], int size);
const int size= 10;
int main()
{
int array[size];
int smallest=FindMin(array,size); //call function usingprototype: dataType FindMin(const dataType anArray[], intsize);
//output results toverify your answer
//Sample output:
cout<<"The Smallest element in the arrayis"<<smallest<<" ";
return 0;
}//end of main
//---------------
int FindMin(const int anArray[], int size)
{
int index;//declare local variables and initialize thevariables for testing
//assume the first element is the smallest
int smallest = anArray[0];
//check each of the remaining elements to find smallest
for(index = 1;index < size;index++)
{
//compare the current smallest to an array element andupdate smallest if necessary
//is an array element smaller than current smallest
if(anArray[index] < smallest)
{
smallest = anArray[index];
}
}
return smallest;
}
Explanation / Answer
#include #include #include using namespace std; int FindMin(const int anArray[], intsize); const int size= 10; int main(){ int array[size] = {10, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int smallest=FindMin(array,size); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.