//
// main.cpp
// Matrix multiplication
//
// Created by Himanshu on 17/09/21.
//
#include <iostream>
using namespace std;
const int N = 2, M = 2;
void multiplyMatrices (int A[N][M], int B[N][M]) {
int C[N][M];
for (int i=0; i<N; i++) {
for (int j=0; j<M; j++) {
C[i][j] = 0;
for (int k=0; k<N; k++) {
C[i][j] += A[i][k]*B[k][j];
}
}
}
cout<<"Multiplcation of Matrices A and B:"<<endl;
for (int i=0; i<N; i++) {
for (int j=0; j<M; j++) {
cout<<C[i][j]<<" ";
}
cout<<endl;
}
}
int main() {
int A[N][M] = {{1, 2}, {3, 4}};
int B[N][M] = {{5, 6}, {7, 8}};
multiplyMatrices(A, B);
}
Ly8KLy8gIG1haW4uY3BwCi8vICBNYXRyaXggbXVsdGlwbGljYXRpb24KLy8KLy8gIENyZWF0ZWQgYnkgSGltYW5zaHUgb24gMTcvMDkvMjEuCi8vCgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMiwgTSA9IDI7Cgp2b2lkIG11bHRpcGx5TWF0cmljZXMgKGludCBBW05dW01dLCBpbnQgQltOXVtNXSkgewogICAgaW50IENbTl1bTV07CiAgICAKICAgIGZvciAoaW50IGk9MDsgaTxOOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqPTA7IGo8TTsgaisrKSB7CiAgICAgICAgICAgIENbaV1bal0gPSAwOwogICAgICAgICAgICBmb3IgKGludCBrPTA7IGs8TjsgaysrKSB7CiAgICAgICAgICAgICAgICBDW2ldW2pdICs9IEFbaV1ba10qQltrXVtqXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIAogICAgY291dDw8Ik11bHRpcGxjYXRpb24gb2YgTWF0cmljZXMgQSBhbmQgQjoiPDxlbmRsOwogICAgCiAgICBmb3IgKGludCBpPTA7IGk8TjsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaj0wOyBqPE07IGorKykgewogICAgICAgICAgICBjb3V0PDxDW2ldW2pdPDwiICI7CiAgICAgICAgfQogICAgICAgIGNvdXQ8PGVuZGw7CiAgICB9CiAgICAKICAgIAp9CiAKaW50IG1haW4oKSB7CiAgICBpbnQgQVtOXVtNXSA9IHt7MSwgMn0sIHszLCA0fX07CiAgICBpbnQgQltOXVtNXSA9IHt7NSwgNn0sIHs3LCA4fX07CiAgICAKICAgIG11bHRpcGx5TWF0cmljZXMoQSwgQik7Cn0K