need help in findin the minimum of these 5 inputs
its keeps showin 2 instead of 1...

#include <iostream>
using namespace std;


int findMin(int [], int);

int main()
{
    const int MAXELS= 5;
    int nums[MAXELS] = {2, 18, 1, 27, 16};
    
    cout << "The minimum value is " << findMin(nums, MAXELS) << endl;
    
    system("pause");
    return 0;
}

// find the minimum value
int findMin(int vals[], int MAXELS)
{
    int i, min = vals[0];
    
    for (i = 1; i >= MAXELS; i++)
    if (min >= vals[i])
    min = vals[i];
    
    return min;
}
for (i = 0; i < MAXELS; i++)

thanks heaps ur a champ!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.