//program perkalian matrik otomatis user//
#include"stdio.h"
main()
{
int a[100][100],b[100][100],c[100][100];
int barisA,kolomA,barisB,kolomB,i,j,k;
//perkalian matrik
do{ printf(" ===Program Perkalian Matrik===\n\n\n");
printf("Masukan matrik A \n");
printf("jumlah baris dan kolom = ");
scanf("%d %d",&barisA,&kolomA);
puts("\n");
printf("Masukan matrik B \n");
printf("jumlah baris dan kolom = ");
scanf("%d %d",&barisB,&kolomB);
puts("\n");
}while(kolomA!=barisB);
//input nilai matrik//
puts("\n\n masukan nilai matrik A ");
for(i=0;i<barisA;i++)
{
for(j=0;j<kolomA;j++)
{printf(" A [%d][%d]= ",i,j);
scanf("%d",&a[i][j]);
}
printf("\n");
}
puts("\n\n masukan nilai matrik B ");
for(i=0;i<barisB;i++)
{
for(j=0;j<kolomB;j++)
{printf(" B [%d][%d]= ",i,j);
scanf("%d",&b[i][j]);
}
printf("\n");
}
//proses perkalian
for(i=0;i<barisA;i++)
{for(j=0;j<kolomB;j++)
{c[i][j]=0;
for(k=0;k<kolomA;k++)
c[i][j]+=a[i][k]*b[k][j];
}
}
//tampilkan matrik
puts("\n ==HASIL PERKALIAN==\n");
for(i=0;i<barisA;i++)
{
for(j=0;j<kolomB;j++)
{
printf("%4d",c[i][j]);
}
printf("\n");
}
}
selamat mencoba ..