Hi ! I need help , I should create an array and the user will enter the values , and display the array and it's values in another function , without using pointers .
so I need help , i don't know what should I write in "displayArray" function
Why did you declare the second parameter of function displayArray as a reference?!
I showed you already how the function is defined. Are you unable to copy and paste the code I showed?
One more for very advanced programmers:
1 2 3 4
void displayArray( constint a, int size )
for ( int i = 0; i < size; i++ ) std::cout << a[i] << ' ';
Further if you defined the array as
then you shall use its size.
So instead of the definition
int a, size = 0;
constint SIZE = 6;
And function readArray shall not ask about the array size. It is fixed and equal to 6. So the function shall ask to enter exactly 6 that is SIZE elements of the array.
Otherwise if the size of the array is not known then you shall allocate it in the heap and use the pointer to its first element.
It is not the problem of the function I showed. It is your problem that you even can not read what other wrote.
Please reread one more my previous message. Function readArray shall be rewritten as I pointed out.