Answer:
#include<iostream>
using namespace std;
//create the function
int minElement(int arr[],int n){
int minimum = arr[0]; //store the first value of array
//for loop for iterate the each element
for(int i=0;i<n;i++){
if(arr[i]<minimum){ //compare
minimum=arr[i];
}
}
return minimum;
}
int main(){
int arr[]={4,1,7,9,2,6};
int array_size = 6;
int result = minElement(arr,array_size); //calling
cout<<"The min value is: "<<result<<endl;
}
Explanation:
First include the library iostream in the c++ programming for input/output.
then, create the function minElement() for find the minimum value in the array.
it required the one loop for iterate the each element in the array and then compare with first element in the array which is store in the variable minimum.
if array element is less than the minimum then, update the value in the minimum variable.
after complete the loop, return the result.
for capture the result create the main function and call the function with parameter array.
and finally display the result.