I have a task which states: "your task is to fill the 10x10 matrix with values that will turn it into a multiplication table. You mustn't use brackets. You mustn't use indexing. Ergo, you must use pointers."
The output should be following: 10x10 multiplication table
That's the solution that I end up with:
#include <iostream>
using namespace std;
int main(void) {
int matrix[10][11] = {};
for(int i = 0; i <= 10; i++) {
for(int j = 0; j <= 10; j++) {
matrix[i-1][j-1]= i*j;
}
}
for(int i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
cout.width(4);
cout << matrix[i][j]; }
cout << endl;
}
}
I tried to think of how can I use pointers instead of indexing, but I could find any information about how to use pointers with two dimensional arrays.
I just started learning C++ and it would be very kind if your help would be descriptive enough for me to understand and in the simplest form.
Thank you!