matrix multiplication in 3*3d enter by the user
-
hi i want to know that there is three loops for matrix multipltication for instance for(i=0;i<3;i++) { for (j=0;j<3;j++) { for(k=0;k<3;k++) know if i want to know abt how i should enter the value in an array and what is the function of theird loop how should i input the value in array 3*3d matrix
-
hi i want to know that there is three loops for matrix multipltication for instance for(i=0;i<3;i++) { for (j=0;j<3;j++) { for(k=0;k<3;k++) know if i want to know abt how i should enter the value in an array and what is the function of theird loop how should i input the value in array 3*3d matrix
If you're declaring a multi-dimensional array (as opposed to a jagged array), then you could do something like this:
double[,,] matrix = new double[3,3,3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
matrix[i, j, k] = i * j * k; // Or whateverA jagged array wouldn't be a whole lot different, but you'd declare it as
double[][][]
and reference elements asmatrix[i][j][k]
. A multi-dimensional array is recommended in this case. You can read more information about the difference by reading about Arrays[^] in the C# Language Specification.Microsoft MVP, Visual C# My Articles