Hi, I'm currently doing remote learning due to COVID-19, so everything I get teaching-wise from my professor is done through videos, in many of which she skips the examples that I feel would be helpful to understand. This is one of them and I have no idea where to start. It's at the beginning of the chapter so it feel like it should be simple.
#include <iostream>
usingnamespace std;
void print_array(int a[], int size);
int main()
{
constint SIZE = 18;
int a[SIZE];
for (int i = 0; i < SIZE; i++)
{
/***Missing Code Here****/
/** I had tried something like
a[i] = i;
if(a[i] > 2)
{
a[i] = a[i] - 2;
}
*/
}
print_array(a, SIZE);
return 0;
}
/**
Prints an array of comma separated int.
@param a the array of strings
@param size the size of the array
*/
void print_array(int a[], int size)
{
cout << "[";
if (size > 0)
{
cout << a[0];
for (int i = 1; i < size; i++)
{
cout << ", " << a[i];
}
}
cout << "]" << endl;
}
Can anyone give me the first idea on how to tackle this? I added the code that I tried before but it gave me the wrong output. Thanks in advance for any help. Just to clarify, this is NOT homework, just a textbook example from Cay Horstmann's Big C++ Late Objects 3rd edition.