1: #include<stdio.h>
2: #include<conio.h>
3: void main()
4: {
5: int i,j,u,v,k,m,x[10][10],y[10][10];
6: printf("Enter the no of row of matrix:");
7: scanf("%d",&k);
8: printf("\nEnter the no of column of matrix:");
9: scanf("%d",&m);
10: printf("Enter the elements:\n");
11: for(i=0;i<k;i++)
12: for(j=0;j<m;j++)
13: {
14: scanf("%d",&x[i][j]);
15: }
16: for(u=0;u<m;u++)
17: for(v=0;v<k;v++)
18: {
19: y[u][v]=x[v][u];
20: }
21: printf("Original Matrix:\n\n");
22: for(i=0;i<k;i++)
23: {
24: for(j=0;j<m;j++)
25: {
26: printf("%3d ",x[i][j]);
27: }
28: printf("\n");
29: }
30: printf("Traspose Matrix:\n\n");
31: for(u=0;u<m;u++)
32: {
33: for(v=0;v<k;v++)
34: {
35: printf("%3d ",y[u][v]);
36: }
37: printf("\n");
38: }
39: getch();
40: }
No comments:
Post a Comment