C Program – Perkalian matriks orde 3×3

#include <stdio.h>
#include <stdlib.h>

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;
    printf("n Perkalian 2 matriksn");
    printf("n Masukan nilai untuk matriksA :");
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("index[%d][%d]=",i,j);
            scanf("%d",&matriksA[i][j]);
        }
    }
    printf("n Masukan nilai untuk matriksB :");
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("index[%d][%d]=",i,j);
            scanf("%d",&matriksB[i][j]);
        }
    }
    //perkalian

    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("n a:n");
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("%d ",matriksA[i][j]);
        }
        printf("n");
    }
    printf("n b:n");
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("%d ",matriksB[i][j]);
        }
        printf("n");
    }
    //hasil
    printf("n Hasiln ");
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("%d ",matriksC[i][j]);
        }
        printf("n");
    }
    getchar();
    getchar();
}

About Iin aryani

I don't wanna be a "Copycat" but, something they need to copy.

Posted on 18 October 2012, in Open Source ( C Program ), Pemrograman C and tagged . Bookmark the permalink. 2 Comments.

  1. ini sudah pernah dicoba di run belum, soalnya aku coba kenapa nga bisa di run

Komentar untuk penulis

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: