I'm doing an exercise where I have to print the original array and add more elements to the array and print those too. So the output should be
Original array:
[10, 20, 30]
After append values to the end of the array:
[10 20 30 40 50 60 70 80 90]
The second part is printing but for some reason, the original array elements won't print.
int arr[9] = {10, 20, 30};
cout << "The original array elements are : " << endl;
for (int i = 0; arr[i] <= 3; ++i)
{
cout << arr[i] << endl;
}
arr[3] = {40};
arr[4] = {50};
arr[5] = {60};
arr[6] = {70};
arr[7] = {80};
arr[8] = {90};
cout << "After append values to the end of the array : " << endl;
for (int j = 0; arr[j] >= 9; ++j)
{
cout << arr[j] << endl;
}
This is the code that I've written, could someone please tell me what I'm doing wrong?