a function that returns the maximum value of an array of real numbers

Asked 2 years ago, Updated 2 years ago, 36 views

I would like to write a program that outputs real numbers in an array from the beginning to the beginning, and that shows the elements of the array and the maximum values in the array, but I couldn't do that with the program shown below.

I'm not sure what's wrong, so if anyone knows, please reply.

/* Store the entered real number data from the beginning of the array */
void readDoubleArray(inta[], int size)
{
    inti;
    for(i=0;i

c

2022-09-30 19:45

1 Answers

The function that looks for the maximum value in double[] will not work (compilation error) with int maxDoubleArray(inta[], int size).Because this function can receive int[] but not double[].

Naming functions and variables is very important and sensible.Just by looking at the name, it would be nice to think that the function name and argument are inconsistent.

double maxDoubleArray(double a[], int size) {...}

Rewrite as shown in should work (untested)

# There are several other tsukkomi, but it doesn't seem to have anything to do with the main story, so it's short


2022-09-30 19:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.