this program uses read() function to input values and print out arrays with print() function
however, i cannot get the arrays printed correctly...
Code:
void read(int[], int);
void print(int[], int);
int main()
{ const int MAXSIZE=100;
int a[MAXSIZE]={0}, size;
read(a,size);
cout<<"The array has "<<size<<" elements: ";
print(a,size);
}
void read(int a[], int n)
{cout<< "Enter integers. Terminate with 0: \n";
n=0;
const int MAXSIZE=100;
do
{cout<< "a["<< n << "] : ";
cin>>a[n];
}while (a[n++] != 0 && n<MAXSIZE);
--n;
}
void print(int a[], int n)
{for (int i=0; i<n; i++)
cout<< a[i]<< " ";
}
it always comes out as 0 array and no values being inserted.
Thanks for the help.