C program to find transpose of a matrix.
Transpose of a matrices in c.
Transpose of a matrix| Transpose of a matrix in C programming | My CS Tutorial
In this tutorial we will learn or discuss that how to write a c program code to find transpose of a matrix. In this program we will use arrays.
This c program code will transpose of a matrix.
In the first user will enter range of rows and columns of matrix. After it user enter the elements of first matrix.
After it compiler check and exicute the condition and logics and print given matrix and transpose the given matrix and print a new matrix in which given matrix is transposed.
C PROGRAM CODE
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,rows,col,temp;
int a[100][100],tra[100][100];
clrscr();
printf("\n ENTER THE NUMBER OF ROWS AND COLUMNS OF A MATRIX:\n ");
scanf("%d %d",&rows,&col);
//Taking input of matrix
printf("\n ENTER FIRST MATRIX:\n ");
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n GIVEN MATRIX IS:\n ");
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n ");
}
//Exchanging rows and columns
temp=rows;
rows=col;
col=temp;
//Transpose of matrix
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
tra[i][j]=a[j][i];
}
}
printf("\n TRANSPOSE OF ABOVE MATRIX IS:\n ");
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
printf("%d\t",tra[i][j]);
}
printf("\n ");
}
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment