further to my commentsl, try this
max gets seeded with the first value, with an optimisation that ignores the loop if there's only one value in the array - technically not needed, the compiler optimiser will build the for loop to essentially do the same thing
i'm assuming the caller is checking for zero values
float max(float vec[], int len)
{
float max=vec[0];
if(len>1)
{
for (int i = 0; i < len; i++)
{
if (vec[i] > max)
{
max = vec[i];
}
}
}
return max;
}