You are on page 1of 2

#include<fstream>

#include<iostream>
using namespace std;

int main()
{

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

ifstream f1;
f1.open("s.txt");

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

for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}

cout<<endl;

ifstream f2;
f2.open("n.txt");

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

for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
cout<<b[i][j]<<"\t";
}
cout<<endl;
}

cout<<endl;
for(int i=0;i<2;i++)
{
for(int j =0 ;j<2;j++)
{
c[i][j] = a[i][j] + b[i][j];
cout<<c[i][j]<<"\t";
}
cout<<endl;
}

You might also like