C Matrix Multiplication Program

C program to designs a program and find a product of the N*M matrix

C

C program to designs a program and find a product of the N*M matrix. – C Programming Me Ham Matrix Multiplication Program Ko Create Karne Wale Hai, Jo Ye Program Array, And Loop Se Banayenge Or Isme Ham Find Karenge Ki N*M Matrix |

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

C Matrix Multiplication Program – N*M

What is Matrix Multiplication N*M In Hindi – Yaha Par Hamne N Or M Liya Hai Jo Ki N,M Number Hai, Or Ye Dono Jab Aapas Me N*M Karenge To Iska Result Hame Mil Jayega. Iska Matlab Yah Ki Hamne N = 1 , M = 1 Liya Hai To Iska Answer Hoga = N*M , 1*1 = 1 And Or Jyada Janne Ke Liye Niche Image Ko Understand Kar Sakte Hai |

Example:

#include<stdio.h>
#include<conio.h>
int main()
{
    int i,j,k,r1,c1,r2,c2,a[' '][' '],b[' '][' '],c[' '][' '];
    printf("\nEnter the no. of rows and columns of matrix 1 : ");
    scanf("%d%d",&r1,&c1);

    printf("\nEnter the no. of rows and columns of matrix 2 : ");
    scanf("%d%d",&r2,&c2);

    if(c1==r2)
    {
    printf("\nEnter the matrix 1\n");
    for(i=0;i<r1;i++)
    {
        for(j=0;j<c1;j++)
        {
            scanf("%d",&a[i][j]);
        }

    }

    printf("\nEnter the matrix 2\n");
    for(i=0;i<r2;i++)
    {
        for(j=0;j<c2;j++)
        {
            scanf("%d",&b[i][j]);
        }

    }

    for(i=0;i<r1;i++)
    {
        for(j=0;j<c2;j++)
        {
            c[i][j]=0;
            for(k=0;k<r1;k++)
            {
                c[i][j]=c[i][j] + a[i][k]*b[k][j];
            }

        }
    }

    printf("\nProduct of matrices\n");
    for(i=0;i<r1;i++)
    {
        for(j=0;j<c2;j++)
        {
            printf("%d\t",c[i][j]);
            printf("\n");
        }

    }
    }
    else
    {
        printf("Matrix multiplication not possible");
        printf("\n");
    }

    getch();
}

Output:

Enter the no. of rows and columns of matrix 1 : 2 2

Enter the no. of rows and columns of matrix 2 : 2 2

Enter the matrix 1
1 2 3 4

Enter the matrix 2
2 0 1 2

Product of matrices
4
4
10
8

More Practice Program:

Friends Mujhe Umeed Hai Ki Aapko C Language program To Generate N*M Matrix In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

MasterPrograming Apps

Leave a Reply

Your email address will not be published. Required fields are marked *