Please can anyone tell me where am i going wrong in this code? | SoloLearn: Learn to code for FREE!

+5

# Please can anyone tell me where am i going wrong in this code?

#include <stdio.h> #include <stdlib.h> void readMatrix(int m[10][10],int rows,int columns) { int i,j; for(i=0;i<rows;i++) { for(j=0;j<columns;j++) { printf("Enter the element matrix %d%d ",i+1,j+1); scanf(" %d",&m[i][j]); } printf("\n"); } } void printMatrix(int m[10][10],int rows,int columns) { int i,j; for(i=0;i<rows;i++) { for(j=0;j<columns;j++) { printf(" %d\t", m[i][j]); } printf("\n"); } } int main() { int i,j,r1,r2,c1,c2; int sum,k; int a[10][10],b[10][10],result[10][10]; printf("Enter the number of rows and columns in matrix A:\n"); scanf(" %d %d",&r1,&c1); readMatrix(a,r1,c1); printMatrix(a,r1,c1); printf("Enter the number of rows and columns in matrix B:\n"); scanf(" %d %d",&r2,&c2); readMatrix(b,r1,c1); printMatrix(b,r2,c2); if(r2==c1) { for(i=0;i<r1;i++) { for(j=0;j<c2;j++) { sum=0; for(k=0;k<r2;k++){ sum = sum +a[i][k]*b[k][j]; } }result[i][j] = sum; } printf("The product of the matrix is :\n"); printMatrix(result,r1,c2); } else { printf("The product is not possible."); } return 0; }

9/29/2018 12:51:52 PM

Jayesh Bhojwani