Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a[10][10],transpose[10][10],i,j,row,col;
- printf("Enter a number of rows and cols for the matrix : ");
- scanf("%d %d",&row,&col);
- for(i=0; i<row; i++)
- {
- for(j=0; j<col; j++)
- {
- printf("a[%d][%d]= ",i,j);
- scanf("%d",&a[i][j]);
- }
- }
- for(i=0; i<row; i++)
- {
- for(j=0; j<col; j++)
- {
- transpose[j][i]=a[i][j];
- }
- }
- //printing the matrix
- printf("\nEntered Matrix = \n");
- for(i=0; i<row; i++)
- {
- printf("\t\t");
- for(j=0; j<col; j++)
- {
- printf("%d ",a[i][j]);
- }
- printf("\n");
- }
- //Transpose the matrix
- printf("\nTranspose Matrix = \n");
- for(i=0; i<col; i++)
- {
- printf("\t\t");
- for(j=0; j<row; j++)
- {
- printf("%d ",transpose[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement