Matrix Calculator

Medium Mini Projects & Algorithmic Challenges
Solve in Playground →

Problem Statement

Write a C++ program executing matrix addition for two 2×2 matrices.

Input Format

Two 2x2 matrices input sequentially.

Output Format

Print resulting 2x2 sum matrix.

Constraints

Matrix elements integers

Sample Input

1 2
3 4
5 6
7 8

Sample Output

6 8
10 12

Explanation

Performs element-wise matrix addition.

Starter Code

#include <iostream>

int main() {
    int a[2][2], b[2][2];
    bool ok = true;
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) if(!(std::cin >> a[i][j])) ok = false;
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) if(!(std::cin >> b[i][j])) ok = false;
    if(ok) {
        // Write your matrix addition logic 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