Home>

Create a function that takes a float type array variable as one of its arguments and returns the maximum, minimum, and total values ​​of the six numbers to the main function. The maximum value, minimum value, and total value use three pointer variables as arguments.

Corresponding source code
#include<stdio.h>
void stat (float data [6], float * max, float * min, float * sum);
int main (void)
{
    float data [6];
    float max, min, sum;
    int i;
    for (i = 0;i<6;i ++)
    {
    printf ("% dth numerical input =", i + 1);
    scanf ("% f",&data [i]);
    }
    stat (data,&max,&min,&sum);

    printf ("maximum value =% f \ n minimum value =% f \ n total value =% f \ n", max, min, sum);

    return 0;
}
void stat (float data [6], float * max, float * min, float * sum)
{
    int i, n = 6;
    for (i = 0;i<n;i ++)
    {
        if (* max<data [i])
        {
            * max = data [i];
        }
    }
    for (i = 0;i<n;i ++)
    {
        if (* min>data [i])
        {
            * min = data [i];
        }
    }
    for (i = 0;i<n;i ++)
    {
    * sum + = data [i];
    }
}
result

Minimum value = -nan

Supplementary information

The maximum value and total value can be output.

c