Matrix (+, -, /, *) and transpose by using Function

Bismillahir Rahmanir Rahim
At first take my salam. how are you, everyone!Now I'm writing a program i think it may be the biggest program in your life(only for beginner ).The problem is find the sum, subtraction, division, multiplication and transpose of two matrix.
see the output:(comment below if you have any problem)
solution:

#include<stdio.h>
int a[3][3],b[3][3],i,j,k;
void input();
void add();
void sub();
void Div();
void Mult();
void trans();
void main()
{
  int n;
  start:
  input();
  printf("The sum of two metrix:\n");
  add();
  printf("The subtraction of two metrix:\n");
  sub();
  printf("The Division of two metrix:\n");
  Div();
  printf("The multiply of two matrix:\n");
  Mult();
  printf("If you want to see the transpose of first and");
  printf("\nsecand matrix press 1\n.");
  printf("Or input again press any digit:\n");
  scanf("%d",&n);
  if(n==1)
   {
    printf("The transpose of first matrix:\n");
    trans();
   }
  else
   goto start;
}
void input()
{
   for(i=0;i<3;i++)
   {
    for(j=0;j<3;j++)
    {
     scanf("%d",&a[i][j]);
    }
  }
  printf("Enter second metrix:\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    scanf("%d",&b[i][j]);
   }     
  }
}
void add()
{
  int c[3][3];
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    c[i][j]=a[i][j]+b[i][j];
    printf("%d\t",c[i][j]);
   }
   printf("\n");
  }
}
void sub()
{
  int d[3][3];
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
    d[i][j]=a[i][j]-b[i][j];
    printf("%d\t",d[i][j]);
   }
   printf("\n");
  }
}
void Div()
{
  int e[3][3];
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
   {
   e[i][j]=a[i][j]/b[i][j];
    printf("%.2f\t",(float)e[i][j]);
   }
   printf("\n");
  }
}
void Mult()
{
 int f[3][3]={0,0,0,0};
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     for(k=0;k<3;k++)
      {
        f[i][j]=f[i][j]+a[j][k]*b[k][j];
      }
     printf("%d\t",f[i][j]);
    }
   printf("\n"); 
  }
}
void trans()
{
 int t_a[3][3],t_b[3][3];
 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     t_a[i][j]=a[j][i];
     printf("%d\t",t_a[i][j]);
    }
   printf("\n");
  }
 printf("The transpose of secand matrix:\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     t_b[i][j]=b[j][i];
     printf("%d\t",t_b[i][j]);
    }
   printf("\n");
  }
}

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