-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Komal-99/transpose_matrix
Transpose matrix
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Enter size of matrix-->3 | ||
Enter the elements of the array | ||
4 7 0 | ||
2 5 8 | ||
4 3 8 | ||
Matrix is | ||
4 7 0 | ||
2 5 8 | ||
4 3 8 | ||
Tranpose of the matrix is | ||
4 2 4 | ||
7 5 3 | ||
0 8 8 | ||
*/ | ||
#include<stdio.h> | ||
|
||
void main() | ||
|
||
{ | ||
int a[20][20],i,j,n; | ||
printf("Enter size of matrix-->"); | ||
scanf("%d",&n); | ||
printf("\n Enter the elements of the array \n"); | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<n;j++) | ||
scanf("%d",&a[i][j]); | ||
} | ||
printf("\n Matrix is\n "); | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<n;j++) | ||
{ | ||
printf("%d ",a[i][j]); | ||
} | ||
printf("\n"); | ||
} | ||
printf("\n Tranpose of the matrix is\n "); | ||
for(j=0;j<n;j++) | ||
{ | ||
for(i=0;i<n;i++) | ||
{ | ||
printf("%d ",a[i][j]); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*to print | ||
input=6 | ||
output= | ||
1 | ||
12 | ||
123 | ||
1234 | ||
12345 | ||
123456 | ||
*/ | ||
#include<stdio.h> | ||
void main() | ||
{ | ||
int a,b,c,rows; | ||
printf("Enter the number of rows: "); | ||
scanf("%d", &rows); | ||
for(a=1;a<=rows;a++) | ||
{ | ||
for(b=rows-1;b>a;b--) | ||
{ | ||
printf(" "); | ||
} | ||
printf("\n"); | ||
for(c=1;c<=a;c++) | ||
{ | ||
printf("%d",c); | ||
|
||
|
||
} | ||
} | ||
} | ||
|
||
|
||
|