forked from itskritibhardwaj/c-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMULMATRI.C
More file actions
112 lines (55 loc) · 1.08 KB
/
Copy pathMULMATRI.C
File metadata and controls
112 lines (55 loc) · 1.08 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* Program to add and multiply two matrices on order NxN */
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5][5],b[5][5],c[5][5],n,i,j,k;
clrscr();
printf("Enter order of the matrix\n");
scanf("%d",&n);
printf("Enter the elements of the first matrix\n");
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
scanf("%d",&a[i][j]);
}
printf("Enter the elements of the second matrix\n");
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
scanf("%d",&b[i][j]);
}
/* Addition of matrices */
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
c[i][j]=a[i][j]+b[i][j];
}
printf("Sum of the matrices is:\n");
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
printf("%d ",c[i][j]);
printf("\n");
}
/* Multiplication of matrices */
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
{
c[i][j]=0;
for(k=0;k<n;k=k+1)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("Multiplication of the matrices is:\n");
for(i=0;i<n;i=i+1)
{
for(j=0;j<n;j=j+1)
printf("%d ",c[i][j]);
printf("\n");
}
getch();
}