Find multiplication of two matrix | C-Program

Multiplication of two matrix: 

Tips:

Create neated loop for:
  1. 1st matrix.
  2.  2nd matix.
  3. Mutilpication of matrix.
  4. Print matix

Code:

#include<stdio.h>

void main()

{
    int n;

    printf("Enter the size of the matrix:\n");

    scanf("%d",&n);

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

    printf("Enter elements of 1st matrix:\n");

    for(i=0;i<=n-1;i++)

    {
        for(j=0;j<=n-1;j++)

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

    printf("Enter the elements of 2nd matrix:\n");

    for(i=0;i<=n-1;i++)

    {
        for(j=0;j<=n-1;j++)

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

    printf("The multiplication is:\n");

    for(i=0;i<=n-1;i++)

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

            {
                sum=0;

                for(k=0;k<=n-1;k++)

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

                c[i][j]=sum;
            }

    for(i=0;i<=n-1;i++)

    {
        for(j=0;j<=n-1;j++)

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

        printf("\n");
    }

    getch();
}

Output: 

Comment for  your feedback!

Comments

Post a Comment

Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :