what if i needed to add a third value to this like address? would it then be a void function? how would that work? void arrayMinMaxAvg (float* array, int size, float* min, float* max, float* avg) - for example, is this even possible?
considering the prototype float minMax (float* array, int size, float* min, float* max); - in c code, how would you write the code for the function? would i include both for loops to find the min and max? i.e. all of below would go in the one function? that doesn't seem right? i'm not sure how to tweek it accordingly?
float minimum(float array[], int size)
{
int i;
float min = array[0]; // min initialized to first element
for(i=1;i<size;i++)
{
if(array[i] < min) //element is compared with min
min = array[i];
}
return min;
}
float maximum(float array[], int size)
{
int i;
float max = array[0]; // max initialized to first element
for(i=1;i<size;i++)
{
if(array[i] > max) //element is compared with max
max = array[i];
}
return max;
-- what if i needed to add a third value to this like address? would it then be a void function? how would that work? void arrayMinMaxAvg (float* array, int size, float* min, float* max, float* avg) - for example, is this even possible?
Step by step
Solved in 5 steps