-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathQ1_Transpose.c
More file actions
41 lines (34 loc) · 758 Bytes
/
Q1_Transpose.c
File metadata and controls
41 lines (34 loc) · 758 Bytes
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
//Name :- Anand Patel Reg. No.:-AM.EN.U4CSE19206 Batch:- S2-CSE
#include <stdio.h>
void transpose(int a[10][10],int);
int main()
{
int i,j;
int a[10][10]; //initializing the 2D-Array
int lim;
printf("Enter the limit : ");
scanf("%d",&lim);
for(i=0;i<lim;i++)
{
for(j=0;j<lim;j++)
scanf("%d",&a[i][j]);
}
printf("The transpose matrix :\n");
transpose(a,lim); //Calling the function transpose
}
void transpose(int a[10][10],int lim)
{
int i,j;
int b[lim][lim];
for(i=0;i<lim;i++)
{
for(j=0;j<lim;j++)
b[i][j]=a[j][i]; //interchanging rows and columns
}
for(i=0;i<lim;i++)
{
for(j=0;j<lim;j++)
printf("%d\t",b[i][j]);
printf("\n");
}
}