My task for this function is to find the index of the <= string in the array. If more than one string, then retrun the smallest index of such string. Retunr -1 if no elements in array.
I came out with a rough code. I hope what I did was in the right direction ..
int indexOfMin(const string a[], int n);
int indexOfMin(const string a[], int n)
{
if (n==0)
{
return -1;
}
else
{
int i = 0;
string min = a[i];
for (i=1; i<n; i++)
{
if (a[i] < min)
{
min = a[i];
}
}
return -1;
}
}