#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int r,c,i=0,j=0,sum=0;
int*ptr;
cout<<"Enter row and column of a matrix";
cin>>r>>c;
ptr=new int[r*c];
cout<<endl<<"Enter elements of the matrix";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>ptr[i*c+j];
}
}
cout<<endl<<"Matrix form";
cout<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
cout<<ptr[i*c+j]<<'\t';
cout<<endl;
}
cout<<endl<<"The Transpose of a matrix is:";
cout<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
cout<<ptr[j*r+i]<<'\t';
cout<<endl;
}
getch();
}
#include<conio.h>
void main()
{
clrscr();
int r,c,i=0,j=0,sum=0;
int*ptr;
cout<<"Enter row and column of a matrix";
cin>>r>>c;
ptr=new int[r*c];
cout<<endl<<"Enter elements of the matrix";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>ptr[i*c+j];
}
}
cout<<endl<<"Matrix form";
cout<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
cout<<ptr[i*c+j]<<'\t';
cout<<endl;
}
cout<<endl<<"The Transpose of a matrix is:";
cout<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
cout<<ptr[j*r+i]<<'\t';
cout<<endl;
}
getch();
}
No comments:
Post a Comment