int FindMin(const intanArray[], int size) { int index;//declare local variables
ID: 3617995 • Letter: I
Question
int FindMin(const intanArray[], 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
if(//is an array element smaller than currentsmallest
anArray[index] < smallest)
{
smallest = anArray[index];
}
}
return smallest;
}
Explanation / Answer
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int FindMin(const int anArray[], int size);
int main(){
int arr[] = {10,9,2,3,2,9,1,0,-1,900};
int size = 10;
int smallest = FindMin(arr,size);
cout << "The smallest is " << smallest << " ";
system("pause");
return 0;
}
int FindMin(const int anArray[], int size){
int index;
//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 and update smallest if necessary
//is an array element smaller than current smallest
if(anArray[index] < smallest){
smallest = anArray[index];
}
}
return smallest;
} Java2html #include <iostream>
#include <fstream>
#include <string>
using namespace std;
int FindMin(const int anArray[], int size);
int main(){
int arr[] = {10,9,2,3,2,9,1,0,-1,900};
int size = 10;
int smallest = FindMin(arr,size);
cout << "The smallest is " << smallest << " ";
system("pause");
return 0;
}
int FindMin(const int anArray[], int size){
int index;
//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 and update smallest if necessary
//is an array element smaller than current smallest
if(anArray[index] < smallest){
smallest = anArray[index];
}
}
return smallest;
} Java2html Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.