The addition, subtruction, division and multiply of Matrix via programming C

Bismillahir Rahmanir Rahim
 hi,friendz,how are you? now i'm showing how solve The addition, subtruction, division and multiply of Matrix via programming C.To solve this problem , you need to know about for loop and array.At first try to solve it .then if you don't solve it see this. If you want to be a good programmer "there is no alternate way of practices"
The solution:

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
#include<stdio.h>
void main()
{
  int i,j,k,a[3][3],b[3][3],c[3][3],e[3][3],g[3][3]={0};
  float f[3][3];
  printf("Enter first metrix:\n");
   for(i=0;i<3;i++)
   {
    for(j=0;j<3;j++)
    {
     scanf("%d",&a[i][j]);
    }
  }
         //iubatians.blogspot.com
  printf("Enter second metrix:\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    scanf("%d",&b[i][j]);
   }
      
  }

  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    c[i][j]=c[i][j]+a[i][j]*b[i][j];
   }
  }
  printf("The sum of two metrix:\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    e[i][j]=a[i][j]+b[i][j];
    printf("%d\t",e[i][j]);
   }
   printf("\n");
  }
  printf("The subtruction of two metrix:\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    c[i][j]=a[i][j]-b[i][j];
    printf("%2d\t",c[i][j]);
   }
   printf("\n");
  }
   printf("The division of two metrix:\n");
   for(i=0;i<3;i++)
   {
    for(j=0;j<3;j++)
    {
     f[i][j]=(float)a[i][j]/(float)b[i][j];
     printf("%.2f\t",f[i][j]);
    }
    printf("\n");
   }

   printf("The multiply of two metrix:\n");
   for(i=0;i<3;i++)
   {
    for(j=0;j<3;j++)
    {
     for(k=0;k<3;k++)
      {
      g[i][j]=g[i][j]+(a[i][k]*b[k][j]);
      printf("(%d*%d)",a[i][j],b[i][j]);
       if(k<2)
         printf("+");
      }
     printf("=%d\t",g[i][j]);
    }
     printf("\n");
  }
}


Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →