15,743,299 members
1.00/5 (1 vote)
See more:
I don't know how to do this problem

What I have tried:

I prompted the user to enter the 10 values
Posted
Updated 20-Feb-23 8:29am

## Solution 3

This way:
C++
```#include <iostream>
using namespace std;

void show_stats( double ad[], size_t size)
{
// show the stats here...
}

int main()
{
}```

or, maybe
C++
```#include <iostream>
#include <array>
using namespace std;

template <typename T, size_t N>
void show_stats( const array<T, N> & a  )
{
// show stats here
}

int main()
{
array<double, 3> ad{ 123.5, 42., -1.2E6};
}```

## Solution 2

In C++ you can pass an array like this:
C++
```int myfkt(int* myarr, int n);

int myarr[] = { 16, 2, 77, 40, 12071 };
int n = sizeof(myarr)/sizeof(myarr[0]);

int result = myfkt(myarr, n);```

v3

## Solution 1

The easiest way is to use the STL container `std::vector`. I will assume that is not an option since you are asking this question. Here is one way to do it, assuming the data is of type double.
C++
```const int ArraySize = 10;

typedef double Array[ ArraySize ];

// wrap this all up in a structure

typedef struct structArrayStr
{
int     Size;
Array   Data;
} ArrayStr;```
Now you can declare an instance of an `ArrayStr`, initialize it, and pass it by reference to a your function.

Alternatively, you don't have to use the structure at all. You can pass the array and its size to the function as separate parameters.