multiplication of two matrix using array

 //

//  main.c

//  multiplication of the two matrix

//

//  Created by ANKIT KUMAR on 19/03/21.

//


#include <stdio.h>

int main()

{

    int i,j,m,n,a[10][10],b[10][10],k,c[10][10];

    printf("enter the number of row and column of the matrix:");

    scanf("%d%d",&m,&n);

    printf("enter the elements of the matrix:\n");

    for(i=0;i<m;i++)

    {

        for(j=0;j<n;j++)

        scanf("%d",&a[i][j]);

        

    }

    printf("enter the element of matrix B:\n");

    for(i=0;i<m;i++)

    {

        for(j=0;j<n;j++)

        scanf("%d",&b[i][j]);

        c[i][j]=0;

        

        

    }

    printf("multiplication of the matrix\n");

    for(i=0;i<m;i++)

    {

        for(j=0;j<n;j++)

        {

            for(k=0;k<m;k++)

            {

                c[k][i]=c[k][i]+a[k][j]*b[j][i];

                

            }

        }

    }

    for(i=0;i<m;i++)

    {

        for(j=0;j<m;j++)

        printf("%5d",c[i][j]);

        printf("\n");

        

    }

  

}

Comments

Popular posts from this blog

Use of function in mathematics

My resume using HTML and CSS