Q:

Write a c program to find transpose of matrix

0

Write a c program to find transpose of matrix

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],i,j,m,n;
printf("number of rows\n");
scanf("%d",&m);
printf("number of columns\n");
scanf("%d",&n);
printf("Enter element of matrix\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Matrix is \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{

printf("%d\t",a[i][j]);
}
printf("\n");

}
printf("Transpose of matrix\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[j][i]);
}
printf("\n");
}
}

Output:

number of rows
2
number of columns
3 2
Enter element of matrix
1 2 4 5
Matrix is 
1	2	
4	5	
Transpose of matrix
1	4	
2	5	

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a c program to input a string and find it’... >>
<< Write a program in c to search an element form arr...