Matrix Multiplication In C

前端 未结 8 2119
后悔当初
后悔当初 2021-02-10 00:01

I\'m trying to solve a matrix multiplication problem with C. Matrix sizes given in problem (2x2) I wrote this code but it doesn\'t print result as I expect. I think I\'m missing

8条回答
  •  执笔经年
    2021-02-10 00:43

    You can have matrix multiplication of any given size by user in the following manner :

    #include
    void main()
    {
        int r1, c1, r2, c2;
    
        printf("Enter number of rows and columns for matrix A : ");
        scanf("%d %d",&r1,&c1);
    
        printf("Enter number of rows and columns for matrix B : ");
        scanf("%d %d",&r2,&c2);
    
        int a[r1][c1], b[r2][c2], ab[r1][c2], ba[r2][c1],i,j,k,temp;
    
        if(c1==r2 && r1==c2)
        {
            printf("\nEnter element in matrix A : ");
            for(i=0;i

提交回复
热议问题