1: #include<stdio.h>
2: #include<stdlib.h>
3:
4: int main()
5: {
6: int i,j;
7: int a[3][3],b[3][3],c[3][3];
8:
9: printf("\nEnter the element of first matrix:\n");
10: for(i=0; i<3; i++)
11: {
12: for(j=0; j<3; j++)
13: {
14: scanf("%d",&a[i][j]);
15: }
16: }
17: printf("\nEnter the elements of second matrix:\n");
18: for(i=0; i<3; i++)
19: {
20: for(j=0; j<3; j++)
21: {
22: scanf("%d",&b[i][j]);
23: }
24: }
25:
26:
27: for(i=0; i<3; i++)
28: {
29: for(j=0; j<3; j++)
30: {
31: c[i][j] = a[i][j] - b[i][j];
32: }
33: }
34:
35: printf("\nThe resultant matrix is:\n");
36: for(i=0; i<3; i++)
37: {
38: for(j=0; j<3; j++)
39: {
40: printf("%d\t",c[i][j]);
41: }
42: printf("\n");
43: }
44: return 0;
45: }
46:
Tuesday, March 1, 2016
Substrating two matrices in C
Labels:
C Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thank you for commenting. Please wait for response :)