forked from sanchitahuja/CP-4th-Sem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13.cpp
More file actions
72 lines (64 loc) · 1.32 KB
/
Copy path13.cpp
File metadata and controls
72 lines (64 loc) · 1.32 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<stdio.h>
int main()
{
int m,n;
float A[20][20],B[20][20],C[20][20],D[20][20];
printf("\n Enter the order of matrices M N : ");
scanf("%d %d",&m,&n);
printf("\nEnter the values for Matrix A \n");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
scanf("%f",&A[i][j]);
}
}
printf("\nEnter the values for Matrix B \n");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
scanf("%f",&B[i][j]);
}
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
C[i][j]=A[i][j]+B[i][j];
D[i][j]=A[i][j]-B[i][j];
}
}
printf("\nMatrix C: \n");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
printf(" %f ",C[i][j]);
}
printf("\n");
}
printf("\nMatrix D: \n");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
printf(" %f " ,D[i][j]);
}
printf("\n");
}
printf("\nTranspose of A :\n");
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
printf(" %f ",A[j][i]);
printf("\n");
}
printf("\nTranspose of B :\n");
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
printf(" %f ",B[j][i]);
printf("\n");
}
}