#include <iostream>
#include <cmath>
usingnamespace std;
// You can't have a function inside another function
double avg(double a[], int size) // Note the parameter
{
for (int i=0; i<size; i++)
{
sum = sum + a[i];
}
return sum / size;
}
int main()
{
// Prompt the user to enter array size
cout << "Enter array size: ";
int arraySize;
cin >> arraySize;
int *numbers = newint [arraySize];
int size = 0;
for (int i = 0; i < arraySize; i++)
{
// Read and store numbers in an array if it is new
cout << "Enter an integer: ";
int value;
cin >> value;
bool isInArray = false;
for (int j = 0; j < size; j++)
//if (*(numbers + j) == value)
if (numbers[j] == value)// This is neater
{
isInArray = true;
break;
}
if (!isInArray)
{
//*(numbers + size) = value;
numbers[size] = value; // This is neater
size++;
}
}
cout << avg(numbers, size) << endl; // Note that you have to call the function avg with () and paramters
return 0;
}