0

im writing a program that creates a dynamic array then input numbers(not exceeding 100).

i used *new int* to create the array. im running into the problem that it only allows 21 numbers to be entered, then does sort,mean. could anyone explain where im going wrong setting up the array or in it usage?

on my specifications(its homework) it shows what functions we need to have in the finished product,*float mean(const int* array, size_t size)*. could anyone explain what size_t is in realtion to this function??

```
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
void sort(int a[], int n);
float mean(int a[], int n);
int main(int argc, char *argv[])
{
int n,g,h;
int size;
int r;
int x;
int i=0,count=0,v=0;
int* array;
array = new int [size];
for(g=0; g<size ;g++) // sets array to 0
{
array[g]=0;
}
cout << "enter intger values" << endl;
do{
for(i= 0; i < size ; i++) // number input
{
cin>>array[i];
}
}while(x >'/' && x<':');
sort( array,size); // sorts numbers
cout << "\n\n\n\n";
for(int i=0;i < size; i++) //shows sorted array
{
cout <<array[i]<<endl;
}
mean(array,size);
system("PAUSE");
return EXIT_SUCCESS;
}
void sort(int a[], int n)
{
int i, j, index, z;
for (i = 0; i < n - 1; i++)
{
index = i;
for (j = i + 1; j < n; j++)
if (a[j] < a[index])
index = j;
if (index != i)
{
z = a[i];
a[i] = a[index];
a[index] = z;
}
}
}
float mean(int a[], int n)
{
int i;
double sum;
double avg;
for(i;i<n;i++)
{
sum+=a[i];
}
avg =((sum)/(n));
cout << "sum: " << sum<<endl;
cout << "avg: " << avg<<setprecision(2)<<setw(2)<<endl;
cout << "\n\n\n";
}
```