-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddtransposematrix.c
More file actions
56 lines (54 loc) · 824 Bytes
/
addtransposematrix.c
File metadata and controls
56 lines (54 loc) · 824 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
#include<stdlib.h>
int **mal(int n);
int main()
{
int **p,**c,**b,i,j;
p=mal(3);
c=mal(3);
b=mal(3);
printf("Enter elements of 3*3 matrix\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d", &p[i][j]);
c[i][j]=p[i][j];
}
printf("\n");
}
printf("Transpose of matrix is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d", p[j][i]);
}
printf("\n");
}
printf("Sum of matrix and its transpose is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[i][j]=c[i][j]+p[j][i];
printf("%d",b[i][j]);
printf(" ");
}
printf("\n");
}
free(c);
free(p);
free(b);
return 0;
}
int **mal(int n)
{
int k;
int**a=(int**)malloc(3*sizeof(int*));
for(k=0;k<3;k++)
{
a[k]=(int*)malloc(3*sizeof(int));
}
return a;
}