This C++ Program will show  the  subtraction of two matrices having same order. First program will initializes the matrices, subtracts each corresponding element of the two matrices and puts the value in the third matrix.

 C++ program which demonstrates subtraction of two matrices having same order is given below. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.

#include <bits/stdc++.h>
using namespace std;

#define n 3
void subtraction(int a[][n], int b[][n], int c[][n]) {
    for (int i = 0; i < n ; i++) {
        for(int j=0; j< n; j++) {
            c[i][j] = a[i][j] - b[i][j];
        }
    }
}

int main() {

    int a[n][n],b[n][n], c[n][n];

    //taking the inpur ot matrix a 
    cout<<"\n Enter the matrice a input:\n";

    for (int i = 0; i < n ; i++) {
        for(int j=0; j< n; j++) {
            cin>>a[i][j];
        }
    }

    //taking the inpur ot matrix a 
    cout<<"\n Enter the matrice b input:\n";

    for (int i = 0; i < n ; i++) {
        for(int j=0; j< n; j++) {
            cin>>b[i][j];
        }
    }

    subtraction(a, b, c);

    //printing the sum matrice i.e output of the addition
    cout<<"\n\n Sum of the matrice a and matrice b is: \n";
    for (int i = 0; i < n ; i++) {
        for(int j=0; j< n; j++) {
            cout<<c[i][j]<< " ";
        }
        cout<<"\n";
    }
}