Answer:
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[10000];//array of ten thousand capacity.
int n=0,min=INT_MAX;//decalring n and min variables.
do{
cin>>a[n];
}while(a[n++]!=0); //using do while loop to take input.
for(int i=0;i<n-1;i++)//looping to n-2th index because 0 is at n-1th index.
{
if(a[i]<min)
{
min=a[i];
}
}
cout<<"The minimum element is "<<min<<endl;//printing the minimum.
return 0;
}
Input:-
5 2 6 78 32 31 21 6 45 2 1 0
Output:-
The minimum element is 1
Explanation:
I have created an array of capacity 10000.Taking input till 0 is entered. Now the 0 is at the n-1 th index so we have to consider elements upto n-2th elements.Using for loop to iterate upto n-2 th index and finding the minimum among those elements.