#include<iostream.h>
#include<process.h>
#include<conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],rowa,cola,rowb,colb,i,j;
cout<<"enter the data for matrix A\n";
cout<<"enter the number of rows=";
cin>>rowa;
cout<<"enter the number of coloumns=";
cin>>cola;
cout<<"enter the data for matrix B\n";
cout<<"enter the number of rows=";
cin>>rowb;
cout<<"enter the number of coloumns=";
cin>>colb;
if((rowa!=rowb)&&(cola!=colb))
{
cout<<"Matrix cannot be added\n";
exit(0);
}
cout<<"Matrix have same order and can be subtracted\npress enter \n";
getch();
clrscr();
cout<<"enter the elements of matrix A\n";
for(i=0;i<rowa;i++)
{
for(j=0;j<cola;j++)
{
cout<<"a["<<i<<"]["<<j<<"]"<<"=";
cin>>a[i][j];
}
}
cout<<"enter the elements of matrix B\n";
for(i=0;i<rowb;i++)
{
for(j=0;j<colb;j++)
{
cout<<"a["<<i<<"]["<<j<<"]"<<"=";
cin>>b[i][j];
}
}
for(i=0;i<rowb;i++)
{
for(j=0;j<colb;j++)
{
c[i][j]=a[i][j]-b[i][j];
}
}
for(i=0;i<rowa;i++)
{
cout<<endl;
for(j=0;j<cola;j++)
{
cout<<c[i][j]<<" ";
}
}
}

In this program firstly we read the matrix using nested for loop in one for loop we increment the value of i for row value from 0 to 1 and in the other for loop we increment the value of j for coloumn value from 0 to 1.after reading the values of the two matrixs we subtract each variable of the two variable which have the same row and coloumn and store the result in the matrix C  at the corresponding address.as that of the matrix variables.