Showing posts with label matrices. Show all posts
Showing posts with label matrices. Show all posts

Friday, September 23, 2016

Matrix Transpose

Program to Calculate Transpose of A Matrix:

#include<iostream>
using namespace std;
main()
{
int a[10][10],b[10][10],m,n,i,j;
cout<<"\nEnter The Order Of Matrix\n";
cin>>m>>n;
cout<<"Enter The Elements Rowwise";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"\na["<<i<<"]["<<j<<"] =";
cin>>a[i][j];
}
}
cout<<"\nTranspose is\n";
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
b[j][i]=a[i][j];
}
for(i=0;i<n;i++)
{ cout<<"\n";
for(j=0;j<m;j++)
{
cout<<b[i][j]<<"\t";
}
}
}

Wednesday, September 7, 2016

PROGRAM TO FIND TRANSPOSE OF A MATRIX

PROGRAM TO FIND TRANSPOSE OF A MATRIX.

#include <iostream>
using namespace std;
int main()
{
    int a[20][20],i,j,m,n;
    cout<<"Enter No. of Rows and Columns of Matrix: ";
    cin>>m>>n;
    cout<<"\nEnter "<<(m*n)<<" Elements of Matrix: ";
    for(i=1; i<=m; i++)
    {
        for(j=1; j<=n; j++)
            cin>>a[i][j];
    }

    cout<<"\nMatrix is:\n";
    for(i=1; i<=m; i++)
    {
        for(j=1; j<=n; j++)
        {
            cout<<a[i][j];
            cout<<'\t';
        }
        cout<<'\n';
    }

    cout<<"\nTranspose of Matrix is:\n";
    for(j=1; j<=n; j++)
    {
        for(i=1; i<=m; i++)
        {
            cout<<a[i][j];
            cout<<'\t';
        }
        cout<<'\n';
    }
    return 0;
    }


Saturday, September 3, 2016

Program to add two matrices: