#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int i,j;
int baris,kolom;
int a[10][10],b[10][10];
int c[10][10];
int temp;
cout<<"masukan jumlah baris =";cin>>baris;
cout<<"masukan jumlah kolom =";cin>>kolom;
cout<<"masukan isi matriks A" <<endl;
for(i=0; i<baris; i++){
for(j=0; j<kolom; j++)
{
cout<<"masukan data ke ["<<i<<","<<j<<"]=";
cin>>a[i][j];
}
}
cout<<"isi matriks A =" <<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
cout<<"isi matriks B =" <<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<b[i][j]<<" ";
}
}
cout<<endl;
}
cout<<endl;
cout<<"hasil penjumlahan matriks A dan B"<<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]+b[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"hasil pengurangan matriks A dan B"<<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]-b[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"perkalian matriks"<<endl;
for(i=0 ;i<2; i++){
for(j=0;j<2; j++){
c[i][j]=0;
for(int z=0;z<2; z++){
temp=a[i][z]*b[i][j];
c[i][j]=c[i][j]+temp;
}
}
}
cout<<endl;
cout<<"hasil perkalian matriks :" <<endl;
for(i=0 ;i<2; i++){
for(j=0;j<2; j++){
cout<<c[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
#include <conio.h>
using namespace std;
int main() {
int i,j;
int baris,kolom;
int a[10][10],b[10][10];
int c[10][10];
int temp;
cout<<"masukan jumlah baris =";cin>>baris;
cout<<"masukan jumlah kolom =";cin>>kolom;
cout<<"masukan isi matriks A" <<endl;
for(i=0; i<baris; i++){
for(j=0; j<kolom; j++)
{
cout<<"masukan data ke ["<<i<<","<<j<<"]=";
cin>>a[i][j];
}
}
cout<<"isi matriks A =" <<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
cout<<"isi matriks B =" <<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<b[i][j]<<" ";
}
}
cout<<endl;
}
cout<<endl;
cout<<"hasil penjumlahan matriks A dan B"<<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]+b[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"hasil pengurangan matriks A dan B"<<endl;
for(i=0 ;i<baris; i++)
{
for(j=0 ;j<kolom; j++)
{
cout<<a[i][j]-b[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"perkalian matriks"<<endl;
for(i=0 ;i<2; i++){
for(j=0;j<2; j++){
c[i][j]=0;
for(int z=0;z<2; z++){
temp=a[i][z]*b[i][j];
c[i][j]=c[i][j]+temp;
}
}
}
cout<<endl;
cout<<"hasil perkalian matriks :" <<endl;
for(i=0 ;i<2; i++){
for(j=0;j<2; j++){
cout<<c[i][j]<<" ";
}
cout<<endl;
}
return 0;
}