Pages

Saturday 19 March 2011

PROGRAM TO FIND THE TRANSPOSE OF GIVEN MATRIX

DESCRIPTION-: This program takes matrix as input and then calculate the transpose of input matrix and after calculating transpose of matrix it generate output matrix.
FOR EXAMPLE-: If we have input matrix as--------

                                1   3   6
                                5   9   2
                                4   1   7

Then program generate output as---------

                                1   5   4
                                3   9   1
                                6   2   7


PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,m,n,a[10][10],b[10][10];
cout<<"enter the number of rows and column of matrix"<<"\n";
cin>>m>>n;
cout<<"enter the value of elements of matrix";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
cout<<"entered matrix is"<<"\n";
for(i=0;i<m;i++)
{
cout<<"\n";
for(j=0;j<n;j++)
{
cout<<a[i][j]<<"\t";
}
}
cout<<"\n transpose of matrix is"<<"\n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
b[i][j]=a[j][i];
}
}
for(i=0;i<n;i++)
{
cout<<"\n";
for(j=0;j<m;j++)
{
cout<<b[i][j]<<"\t";
}
}
getch();
}

0 comments:

Post a Comment

 
Copyright (c) 2010 Concepts Of C++. Design by WPThemes Expert

Blogger Templates and RegistryBooster.