This is the error: cannot convert 'double ( * )[3]' to 'int (*)[3] transpose(matrixA, matrixB); but the same code is working when I'm changing the data type to int. How can I fix my code?
#include <iostream>
using namespace std;
#define M 3
#define N 4
// This function stores transpose of A[][] in B[][]
void transpose(double A[][N], int B[][M])
{
double i, j;
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
B[i][j] = A[j][i];
}
// This function prints the elements of the matrix.
void print(double matrix[][M])
{
cout << "The resultant matrix is" << endl;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
cout << matrix[i][j] << " ";
cout << endl;
}
}
int main()
{
double matrixA[M][N] = {{1.3, 2, 3, 4.5},
{5, 6.6, 7.8, 8},
{4.7, 5, 3, 2.9}};
double matrixB[N][M], i, j;
transpose(matrixA, matrixB);
print(matrixB);
return 0;
}
Thank You