Embed presentation
Download to read offline
![INPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
int m[3][3],i,j;
clrscr();
cout<<"n Enter the element in (3*3)Matrix:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>m[i][j];
}
}
cout<<"nMatrix is:n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"n";
}
cout<<"nTRANSPOSE OF MATRIX IS:n";
1](https://image.slidesharecdn.com/ooprc4b-190823025229/75/Ooprc4-b-1-2048.jpg)
![for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<m[j][i]<<" ";
}
cout<<"n";
}
getch();
}
OUTPUT:
2](https://image.slidesharecdn.com/ooprc4b-190823025229/85/Ooprc4-b-2-320.jpg)

This C++ program accepts a 3x3 matrix from the user as input, prints out the original matrix, and then prints the transpose of that matrix - with the rows and columns swapped. The user is prompted to enter 9 integers to populate a 2D array representing the 3x3 matrix. Two nested for loops print out the original matrix and then the program uses the same nested loop structure with the rows and columns swapped to print the transpose of the input matrix.
![INPUT:
#include<iostream.h>
#include<conio.h>
void main()
{
int m[3][3],i,j;
clrscr();
cout<<"n Enter the element in (3*3)Matrix:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>m[i][j];
}
}
cout<<"nMatrix is:n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"n";
}
cout<<"nTRANSPOSE OF MATRIX IS:n";
1](https://image.slidesharecdn.com/ooprc4b-190823025229/75/Ooprc4-b-1-2048.jpg)
![for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<m[j][i]<<" ";
}
cout<<"n";
}
getch();
}
OUTPUT:
2](https://image.slidesharecdn.com/ooprc4b-190823025229/85/Ooprc4-b-2-320.jpg)