How can I find the minimum value from a vector?
int main()
{
int v[100] = { 5, 14, 2, 4, 6 };
int n = 5;
int mic = v[0];
enter code here
for (int i=0; i < v[n]; i++)
{
if (v[i] < mic)
mic = v[i];
}
cout< < mic;
}
But is not working, what can I do?
You have an error in your code. This line:
should be
because you want to search
nplaces in your vector, notv[n]places (which wouldn’t mean anything)