SCREENSHOT
CODING
Strats From Here ------>>
#include<iostream.h>
#include<conio.h>
void main()
{ int s,x,i,j,k,a[5][5],b[5][5],r[5][5];
clrscr();
cout<<"Enter no. of rows & column(should be rows=column):";
cin>>s;
cout<<"\n\tChoose Your Required Matrices Operation";
cout<<endl<<"1)Addition of two matrices.";
cout<<endl<<"2)Subtraction of two matrices.";
cout<<endl<<"3)Multiplication of two matrices.";
cout<<endl<<"\t\tEnter Your Choice:";
cin>>x;
cout<<endl<<"\t\tFirst Matrix:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cin>>a[i][j];
cout<<endl;
}
cout<<"\t\tSecond Matrix:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cin>>b[i][j];
cout<<endl;
}
clrscr();
cout<<"\nFirst Matrix\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<a[i][j];
cout<<endl<<endl;
}
cout<<"\nSecond Matrix\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<b[i][j];
cout<<endl<<endl;
}
switch (x)
{ case 1:
cout<<"\t\tAddition of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
r[i][j]=a[i][j]+b[i][j];
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
case 2:
cout<<"\t\tSubtraction of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
r[i][j]=a[i][j]-b[i][j];
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
case 3:
cout<<"\t\tMultiplication of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
{ r[i][j]=0;
for(k=0;k<s;k++)
r[i][j]=r[i][j]+a[i][k]*b[k][j];
}
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
default:
cout<<"\nYOU ENTERED WRONG OPTION";
}
getch();
}
#include<conio.h>
void main()
{ int s,x,i,j,k,a[5][5],b[5][5],r[5][5];
clrscr();
cout<<"Enter no. of rows & column(should be rows=column):";
cin>>s;
cout<<"\n\tChoose Your Required Matrices Operation";
cout<<endl<<"1)Addition of two matrices.";
cout<<endl<<"2)Subtraction of two matrices.";
cout<<endl<<"3)Multiplication of two matrices.";
cout<<endl<<"\t\tEnter Your Choice:";
cin>>x;
cout<<endl<<"\t\tFirst Matrix:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cin>>a[i][j];
cout<<endl;
}
cout<<"\t\tSecond Matrix:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cin>>b[i][j];
cout<<endl;
}
clrscr();
cout<<"\nFirst Matrix\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<a[i][j];
cout<<endl<<endl;
}
cout<<"\nSecond Matrix\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<b[i][j];
cout<<endl<<endl;
}
switch (x)
{ case 1:
cout<<"\t\tAddition of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
r[i][j]=a[i][j]+b[i][j];
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
case 2:
cout<<"\t\tSubtraction of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
r[i][j]=a[i][j]-b[i][j];
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
case 3:
cout<<"\t\tMultiplication of two matrices:-\n";
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
{ r[i][j]=0;
for(k=0;k<s;k++)
r[i][j]=r[i][j]+a[i][k]*b[k][j];
}
}
for(i=0;i<s;i++)
{ for(j=0;j<s;j++)
cout<<"\t"<<r[i][j];
cout<<endl;
}
break;
default:
cout<<"\nYOU ENTERED WRONG OPTION";
}
getch();
}
<<<<------- End Here