When inputting a array in c++ the element in 0th position will become the length of the array. have two functions to input and print the array when print function calls the output array has always the array length in 0th position.
#include<iostream>
using namespace std;
int getArray(int array[])
{
int len;
cout << "Enter the length of the array" << endl;
cin >> len;
cout << "Enter the elements in the array" << endl;
for (int i = 0; i < len; ++i)
{
cin >> array[i];
}
return len;
}
void printArray(int array[], int len)
{
for (int i = 0; i < len; i++)
{
cout << array[i];
}
}
int main(int argc, char const *argv[])
{
int array[] = {};
int len = getArray(array);
printArray(array, len);
return 0;
}