Langsung saja ini syntaxnya.
#include <stdio.h>Sehingga jika di Compile akan menghasilkan Output seperti gambar dibawah ini.!
#include <stdlib.h>
//Author : Muh. Fachrial Yuni Yunizar
int main()
{
int matriksA[3][3];
int matriksB[3][3];
int matriksC[3][3]= {(0,0,0),(0,0,0),(0,0,0)};
int i,j,k;
int n=10;
printf("\n======================================\n");
printf(" APLIKASI PERKALIAN MATRIX 2 DIMENSI \n");
printf("======================================\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
matriksA[i][j]=rand()%n;
}
}
for(i=0;i<3;i++){
for(j=0;j<3;j++){
matriksB[i][j]=rand()%n;
}
}
for(i=0;i<3;i++){
for(j=0;j<3;j++){
for(k=0;k<3;k++){
matriksC[i][j]+=matriksA[i][k]*matriksB[k][j];
}
}
}
printf("\nNilai Matrix a: \n");
printf("\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf(" %d ",matriksA[i][j]);
}
printf("\n \n");
}
printf("\nNilai Matrix b: \n");
printf("\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf(" %d ",matriksB[i][j]);
}
printf("\n \n");
}
printf("\nHasil Perkalian\n");
printf("\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf(" %d ",matriksC[i][j]);
}
printf("\n \n");
}
printf("\n");
printf("======================================\n");
getchar();
getchar();
}
Bahasa C |
0 Response to "Aplikasi Perkalian Matrix 2 Dimensi - Bahasa C"
Post a Comment