#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,M,N;
int A[10][10], B[10][10];
int transpose(int A[][10], int r, int c); /*Function prototype*/
clrscr();
printf(“Enter the order of matrix A\n”);
scanf(“%d %d”, &M, &N);
printf(“Enter the elements of matrix\n”);
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
scanf(“%d”,&A[i][j]);
}
}
printf(“Matrix A is\n”);
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf(“%3d”,A[i][j]);
}
printf(“\n”);
}
/* Finding Transpose of matrix*/
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
B[i][j] = A[j][i];
}
}
printf(“Its Transpose is\n”);
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf(“%3d”,B[i][j]);
}
printf(“\n”);
}
} /*End of main()*/
/*—————————————
Output
Enter the order of matrix A
3 3
Enter the elements of matrix
1
2
3
4
5
6
7
8
9
Matrix is
1 2 3
4 5 6
7 8 9
Its Transpose is
1 4 7
2 5 8
3 6 9
—————————–*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
- C program to read N integers (zero, +ve and -ve) into an array A and to a) Find the sum of negative numbers b) Find the sum of positive numbers and c) Find the average of all input numbers Output the various results computed with proper headings
- Sample – Program to find the sum of each row & column of a matrix of size n x m and if matrix is square, find the sum of the diagonals also..
- Sample – Program to find the sum of either of the diagonals of a 4 x 4 matrix.
- C program to input real numbers and find the mean, variance and standard deviation
