bostang / matrixMultiplication

Repository ini dibuat untuk memenuhi **Tugas 5** mata kuliah `EL2008 : pemecahan Masalah dengan C`
0 stars 0 forks source link

Format umum #2

Closed DaffaITB closed 2 years ago

DaffaITB commented 2 years ago

Kayak gini bikin beberapa file tinggal masukin n={bentuk matriks} ?

#include<stdio.h>

int main() {

    int i,j,k,a[n][n],b[n][n];
    int row1,col1,row2,col2,c[n-1][n-1];

    row1 = n;
    col1 = n;
    row2 = n;
    col2 = n;

    printf("enter the values of matrix1\n");
    for(i=0;i<row1;i++) {
        for(j=0;j<col1;j++){
            scanf("%d",&a[i][j]);
        }
    }

    printf("enter the values of matrix2\n");
    for(i=0;i<row2;i++) {
        for(j=0;j<col2;j++) {
            scanf("%d",&b[i][j]);
        }
    }

    printf("Multiplication:\n");
    for(i=0;i<row1;i++){
        for(j=0;j<col2;j++) {
            c[i][j]=0;
            for(k=0;k<row2;k++) {
                c[i][j]+=a[i][k]*b[k][j];
            }
        printf("%d ",c[i][j]);
        }
    printf("\n");
    }

}