top of page

C Program to Multiply two Matrices

Matrix multiplication in C:



#include<stdio.h>

#include<conio.h>

void main()

{

int a[15][15],b[15][15],c[15][15],row, col, i, j, k;

clrscr();

printf("Enter the number of row of Matrix: ");

scanf("%d", &row);

printf("Enter the number of column of Matrix: ");

scanf("%d", &col);

printf("Enter element of first Matrix: \n");

for(i=0;i<row;i++)

{

for(j=0;j<col;j++)

{

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

}

}


printf("Enter elements of Second Matrix: \n");

for (i=0;i<row;i++)

{

for(j=0;j<col;j++)

{

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

}

}

printf("multiply of the two matrix: \n");

for(i=0;i<row;i++)

{

for(j=0;j<col;j++)

{

c[i][j]=0;

for(k=0;k<col;k++)

{

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

}

}

}

for (i=0;i<row;i++)

{

for(j=0;j<col;j++)

{

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

}

printf("\n");

}

getch();

}

Output:

Enter the number of row of Matrix: 2

Enter the number of column of Matrix: 2

Enter element of first matrix:

1 1

2 2

Enter elements of Second Matrix:

1 1

2 2

multiply of the two matrix:

3 3

6 6



9 views0 comments

Recent Posts

See All

1. The output of the following code. string=”my name is x” for i in string: print(i,end=”,”) A. m,y,,n,a,m,e,,i,s,x, B. m,y,,n,a,m,e,,i,s,x C. my,name,is,x D. None Answer: (A) 2. What arit

1. What is the full form of IoT? A. Internet of Technology B. Incorporate of Things C. Internet of Things D. Incorporate of Technology Answer: C 2. How many numbers of the element

bottom of page