PROGRAM-19


// Program to product of two matrices
#include
#include
void main()
{
  clrscr();
  int matA[10][10], matB[10][10], prodmat[10][10];
  int n,i,j,k,row1,col1,row2,col2;
  printf("Enter the order of matrixA\n");
  scanf("%d*%d", &row1,&col1);
  printf("Enter the order of matrixB\n");
  scanf("%d*%d", &row2,&col2);
  if(col1==row2)
     {
                printf("Enter the element of matrixA\n");
                for(i=0;i
                {
                   for(j=0;j
                     {
                     scanf("%d", &matA[i][j]);
                   }
     }
  printf("Enter the element of matrixB\n");
                for(i=0;i
     {
                for(j=0;j
                {
                  scanf("%d", &matB[i][j]);
                }
     }
                for(i=0;i
                {
                  for(j=0;j
                  {
                   prodmat[i][j]=0;
                   for(k=0;k
                   {
                   prodmat[i][j]=prodmat[i][j]+(matA[i][k]*matB[k][j]);
                   }
                  }
                 }
                 printf("Product matrix is \n");
                for(i=0;i
                {
                  for(j=0;j
                  {
                    printf("%3d", prodmat[i][j]);
                  }
                  printf("\n");
                  }
       }
       else
       printf("multiplication is not possible  \n");
       getch();
}

Algorithm

·                     Start
·                     Declare matA[10][10],  matB[10][10],  prodmat[10][10] as integer
·                       Declare n, i, j, k, row1, col1, row2, col2 as integer
·                       Write("the order of matrixA")
·                       Read(“row1 and col1”)
·                       Write("the order of matrixB")
·                       Read(“row2 and col2”)
·                       if(col1==row2)
·                     Read("Enter the element of matrixa")
·                     for(i=0;i
·                     for(j=0;j
·                     Read(“matA[i][j]”)
·                     printf("the element of matrixB")
·                     for(i=0;i
·                     for(j=0;j
·                     Read(“matB[i][j]”)
·                     for(i=0;i
·                     for(j=0;j
·                     prodmat[i][j]=0
·                     for(k=0;k
·                     prodmat[i][j]=prodmat[i][j]+(matA[i][k]*matB[k][j])
·                     Read("the Product matrix ")
·                     for(i=0;i
·                     for(j=0;j
·                     Read("the prodmat[i][j])
·                     write("in next line")
·                     else
·                     Write("multiplication is not possible")
·                     Stop


#vpsinghrajput

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

1 comments: