Program to find Transpose of Matrix in C++

Here is the Program to find Transpose of Matrix in C++ PROGRAM: #include<iostream> using namespace std; int main() { int a[10][10],m,n,i,j; cout<<"Enter number of rows: "; cin>>m; cout<<"Enter number of coloumns: "; cin>>n; if(m!=n) { cout<<"Matrix not square so Transpose not possible :("; } else { cout<<endl<<"Enter elements of matrix: "<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { … Read more

Matrix multiplication in C++

How matrix multiplication in C++ Works:   Input two matrices. Run 3 for loops (i,j,k). Multiplication will be addition of First_Matrix[i][k]*Second_Matrix[k][j] for each element. Resultant matrix is stored in third Matrix.   CODE: #include<iostream> using namespace std; int main(){ //Using const int for array size const int row=2,col=2; // if not use const error found … Read more

Addition of two matrix in C++

How It Works: For 2D array size there must be constant value in square brackets like  array[constant value][constant value].   Two const variables row and col are used to define size. if we do not make both const then error found because without const reserve word they are behaving as variable. Before placing both variable … Read more