C 语言中的矩阵乘法

2025 年 3 月 25 日 | 阅读 2 分钟

C 语言中的矩阵乘法:我们可以对 2 个矩阵进行加法、减法、乘法和除法运算。为此,我们从用户那里获取行号、列号、第一个矩阵元素和第二个矩阵元素的输入。然后我们对用户输入的矩阵执行乘法运算。

在矩阵乘法中,第一个矩阵的一行元素乘以第二个矩阵的所有列元素

让我们通过下图来理解 2*2 和 3*3 矩阵的乘法

matrix multiplication program in c

让我们看看 C 语言中的矩阵乘法程序。

示例

编译并运行

输出

enter the number of row=3
enter the number of column=3
enter the first matrix element=
1 1 1
2 2 2
3 3 3
enter the second matrix element=
1 1 1
2 2 2
3 3 3
multiply of the matrix=
6 6 6
12 12 12
18 18 18

让我们通过下图来理解 3*3 和 3*3 矩阵的乘法

matrix multiplication in c