Matrix Multiplication

Medium 2D Arrays (Matrices)
Solve in Playground →

Problem Statement

Write a C program to multiply two matrices A (R1 x C1) and B (R2 x C2), where C1 == R2.

Input Format

Line 1: R1 C1. Matrix A. Line: R2 C2. Matrix B.

Output Format

Print the product matrix of size R1 x C2.

Constraints

1 <= R1, C1, R2, C2 <= 5

Sample Input

2 2
1 2
3 4
2 2
5 6
7 8

Sample Output

19 22
43 50

Explanation

Standard matrix multiplication product of A and B.

Starter Code

#include <stdio.h>

int main() {
    int r1, c1, r2, c2;
    if (scanf("%d %d", &r1, &c1) == 2) {
        int a[r1][c1];
        for(int i=0; i<r1; i++) for(int j=0; j<c1; j++) scanf("%d", &a[i][j]);
        if (scanf("%d %d", &r2, &c2) == 2) {
            int b[r2][c2];
            for(int i=0; i<r2; i++) for(int j=0; j<c2; j++) scanf("%d", &b[i][j]);
            // Write your code here
        }
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used