Why the below C code is not running properly? | Sololearn: Learn to code for FREE!

+1

Why the below C code is not running properly?

//Matrix multiplication #include <stdio.h> #include <conio.h> int main() { int a[10][10],B[10][10],C[10][10],i,j,k,sum,m,n,p,q; sum=0; //clrscr(); printf("enter the size of matrix (row*column) A\n"); scanf("%d%d",&m,&n); printf("enter the size of matrix (row*column) B\n"); scanf("%d%d",&p,&q); if(n!=p) { printf("\nmultiplication is not possible"); } else { printf("\nenter elements for matrix A:\n"); for(i=0;i<m;i++); { for(j=0;j<n;j++); { printf("\nelement A[%d][%d]=",i,j); scanf("%d",&a[i][j]); } } printf("\nenter elements for matrix B:\n"); for(i=0;i<p;i++); { for(j=0;j<q;j++); { printf("\nelement B[%d][%d]=",i+1,j+1); scanf("%d",&B[i][j]); } } //now multiplication for(i=0;i<m;i++); { for(j=0;j<q;j++); { sum=0; for(k=0;k<p;k++) { sum=sum+a[i][k]*B[k][j]; C[i][j]=sum; } } } //printing result for(i=0;i<m;i++); { for(j=0;j<q;j++); { printf("%d\t",C[i][j]); } printf("\n"); } return 0; }}

4/12/2021 12:31:07 PM

Coding Gl

4 Answers

New Answer

+7

Almost all of your *for* loops are doing nothing as you have terminated them with a semicolon . Also <conio.h> is a non standard header and is not supported by most of the modern standard compilers.

+3

Arsenic 👍

+1

Check the syntax

0

Do not use semicolon after for loop.