-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatTranspose.c
50 lines (42 loc) · 1.15 KB
/
MatTranspose.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//C Program to do Matrix Transposing.
#include <stdio.h>
//Function to print Matrix.
int PrintMatrix(int print[10][10], int rows, int columns){
int i, j;
for(i=0; i<rows; i++){
for(j=0; j<columns; j++){
printf("\t%d", print[i][j]);
}
printf("\n");
}
}
//Function to take Transpose of Matrix
int TransposeMatrix(int tp[10][10], int rows, int columns){
int i, j;
for (int i=0; i<columns; i++){
for (int j=0; j<rows; j++){
printf("\t%d", tp[j][i]);
}
printf("\n");
}
}
int main(){
int matrix[10][10];
int i, j, rows, columns;
printf("Enter no. of rows & column:"); //Getting no. of Rows & Columns
scanf("%d %d", &columns, &rows);
//Getting values of the Matrix.
printf("\n\n\nEnter value of the Matrix\n");
for(i=0; i<rows; i++){
for(j=0; j<columns; j++){
printf("\nEnter Matrix[%d][%d] value:", i, j);
scanf("%d", &matrix[i][j]);
}
}
//Printing Matrix 1
printf("\t\t\nInput Matrix 1\n");
PrintMatrix(matrix, rows, columns);
//Printing Transpose of Matrix
printf("\t\t\nTranspose of Matrix 1\n");
TransposeMatrix(matrix, rows, columns);
}