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?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 28SA
icon
Related questions
Question

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?

Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning