From e200b5ec8968295e66cb85651433c769d4e6f39e Mon Sep 17 00:00:00 2001 From: RAJEEVGUPTA950 <115412135+RAJEEVGUPTA950@users.noreply.github.com> Date: Sun, 9 Oct 2022 20:13:41 +0530 Subject: [PATCH] Create array_matrixmultiply.cpp --- arrays/array_matrixmultiply.cpp | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 arrays/array_matrixmultiply.cpp diff --git a/arrays/array_matrixmultiply.cpp b/arrays/array_matrixmultiply.cpp new file mode 100644 index 0000000..a0650a5 --- /dev/null +++ b/arrays/array_matrixmultiply.cpp @@ -0,0 +1,49 @@ +#include +int main() +{ + int m, n, p, q, c, d, k, sum = 0; + int fir[10][10], sec[10][10], mlty[10][10]; + + printf("ENTER THE ROW AND COLOMN \n"); + scanf("%d%d",&m,&n); + printf("\n FIRST MATRIX NEED TO ONE WITH ONE SPACE AND AFTER THREE WITH ENTER \n"); + for (c = 0; c < m; c++){ + for (d = 0; d < n; d++){ + scanf("%d", &fir[c][d]); + } +} + printf("\n ENTER THE ROW AND COLOMN:\n"); + scanf("%d%d", &p, &q); + if (n != p) + printf("\n FOR MULTYPLY NEED TO N=P \n"); + else + { + printf("\n SECOND MATRIX NEED TO ONE WITH ONE SPACE AND AFTER THREE WITH ENTER \n"); + for (c = 0; c < p; c++){ + for (d = 0; d < q; d++){ + scanf("%d", &sec[c][d]); +} +} + for (c = 0; c < m; c++) { + for (d = 0; d < q; d++) { + for (k = 0; k < p; k++) { + sum = sum + fir[c][k]*sec[k][d]; + } + + mlty[c][d] = sum; + sum = 0; + } + } + + printf("THE MULTYPLY IS::\n"); + + for (c = 0; c < m; c++) { + for (d = 0; d < q; d++) + printf("|%d\t|", mlty[c][d]); + + printf("\n"); + } + } + + return 0; +}