Program to find transpose of a matrix by using multi-dimensional arrays.

Find Transpose of a Matrix by Using Multi-dimensional Arrays

Program to find transpose of a matrix by using multi-dimensional arrays.

Object: Write a C++ program to find transpose of a matrix by using multi-dimensional arrays. C++ Projects

Code:

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int mat[4][5],i,j;
cout<<“Enter matrix values:\n”;
for(i=0;i<4;i++)
{
for(j=0;j<5;j++)
{
cin>>mat[i][j];
}
}
cout<<endl;
for(i=0;i<4;i++)
{
cout<<“[ “;
for(j=0;j<5;j++)
{
cout<<mat[i][j]<<” “;
}
cout<<“]”<<endl;
}
cout<<” \nTranspose of the matrix is:\n”;
for(i=0;i<5;i++)
{
cout<<“[ “;
for(j=0;j<4;j++)
{
cout<<mat[j][i]<<” “;
}
cout<<“]”<<endl;
}
getch();
}

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	int mat[4][5],i,j;
	cout<<"Enter matrix values:\n";
	for(i=0;i<4;i++)
	{
		for(j=0;j<5;j++)
		{
			cin>>mat[i][j];
		}
	}
	cout<<endl;
	for(i=0;i<4;i++)
	{
		cout<<"[ ";
		for(j=0;j<5;j++)
		{
			cout<<mat[i][j]<<" ";
		}
		cout<<"]"<<endl;
	}
	cout<<" \nTranspose of the matrix is:\n";
	for(i=0;i<5;i++)
	{
		cout<<"[ ";
		for(j=0;j<4;j++)
		{
			cout<<mat[j][i]<<" ";
		}
		cout<<"]"<<endl;
	}
	getch();
}	

Output:

Program to find transpose of a matrix by using multi-dimensional arrays.

C++ projects for beginners with source code

2 thoughts on “Program to find transpose of a matrix by using multi-dimensional arrays.”

  1. Pingback: C++ projects for beginners with source code - Codeboks

Leave a Comment

Your email address will not be published. Required fields are marked *