как рандомный массив вставить в функцию в чём ошибка

в строке cout << average(arr, n) << endl; Ошибка (активно) E0167 аргумент типа "void (*)(int *a, int n)" несовместим с параметром типа "int *"

#include <iostream>
#include <iomanip>
#include <locale.h>
#include <ctime>
#include<stdio.h>

// C++ program to calculate average of array elements
#include <iostream>
using namespace std;

// Функция создает динамический массив
void arr(int* a, int n) {
    srand(time(NULL));
    for (int i = 0; i < n; i++)
        a[i] = rand() % (n * n);
    cout << "Случайный динамический массив:" << endl;
}

// Function that return average of an array.
double average(int* a, int n)
{
    // Find sum of array element
    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];

    return (double)sum / n;
}

// Driver code
int main()
{
    setlocale(LC_ALL, "Russian");
    //размер массива n
    int n;
    cout << "Введите размер массива" << endl;
    cin >> n;
    int* a = new int[n];
    for (int i = 0; i < n; i++)
        a[i] = 0;
    arr(a, n);
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }


    cout << average(arr, n) << endl;
    return 0;
}

Ответы (1 шт):

Автор решения: harpCS

Передайте a а не arr в функцию:

cout << average(a, n) << endl;
→ Ссылка