i function to print an array normally which works. it is an array of 9 ints. i am trying to display it as a 3*3 matrix. For example:
normal print:
1 2 3 4 5 6 0 0 0
expected output:
1 2 3
4 5 6
0 0 0
Here is the code that first came to mind because for the life of me i could not find a way to use loops to achieve this
void printArray (int arr[], int n)
{
cout << arr[0] << " " <<arr[1] << " " <<arr[2] << endl;
cout << arr[3] << " " <<arr[4] << " " <<arr[5] << endl;
cout << arr[6] << " " <<arr[7] << " " <<arr[8] << endl;
}
i am only using a 1D array.