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



8 views0 comments

Recent Posts

See All

Group Flights Gone are the days when people like to fly all along. As the Standard of living is increasing by leap and bond, people to show their influence or to impression many offers to take on a gr

CSS MCQ Q 1. What is CSS? a. CSS is a style sheet language b. CSS stands for Cascading style sheet. c. CSS is used to style the HTML documents d. All of the mentioned Answer: d Q

HTML MCQ: Q. HTML Full form: a. HighText Machine Language b. HyperText and links Markup Language Hyper Text Marquee Language HyperText Markup Language Answer: d Q. The correct sequence of