Skip to content

Commit

Permalink
Merge pull request #24 from Komal-99/transpose_matrix
Browse files Browse the repository at this point in the history
Transpose matrix
  • Loading branch information
unnati914 authored May 25, 2021
2 parents 232e85b + 4d9d345 commit 5c6498c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Matrix_programs/Transpose_of_matrix.cpp
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");
}

}
34 changes: 34 additions & 0 deletions patterns/number_half_pyramid.cpp
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);


}
}
}



0 comments on commit 5c6498c

Please sign in to comment.