Through the debugger you may write explicitly in the watch window A[2][1]
etc..
Edited - after the code presented:
int main() {
double **A;
double M = 4;
A = new double *[M]; //define M by M matrix
for( int k =0; k < M; k++) {
A[k] = new double [M];
}
//assign values to matrix
for (int i = 0; i < M; i++) {
for (int j = 0; j < M; j++) {
if ( j == i) {
A[i][j] = 2;
} else {
A[i][j] = 1;
}
}
}
return 0;
}
I put break point on the return 0
and add some test values to the watch window:
A[0][0] 2.0000000000000000 double
A[0][1] 1.0000000000000000 double
A[0][2] 1.0000000000000000 double
A[1][0] 1.0000000000000000 double
A[1][1] 2.0000000000000000 double
A[1][2] 1.0000000000000000 double
It seems fine. What do you get when you're doing the same? Where is the problem?
You can also print the values to screen as MatrixFrog suggested.