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

Q1. The signal is transmitted in an optical fibre? A. Due to total internal reflection B. Due to external reflection C. In straight line path D. None of Above Ans: A Q2. Wi-Fi stan

Q 1. The maximum motion of Data transmission in dial up connection is……….. A. 56 kbps B. 512kbps C. 32kbps D. 8kbps Ans: A Q2. Which provides very slow internet connection service?

bottom of page