This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Tampilkan postingan dengan label program perkalian matriks a dan b. Tampilkan semua postingan
Tampilkan postingan dengan label program perkalian matriks a dan b. Tampilkan semua postingan

Senin, 05 Maret 2012

program perkalian matriks a dan b

#include<stdio.h>
#include <stdlib.h>
   
    int main()
    {
      int A[2][2], B[2][2], C[2][2];
      int i,j;
      printf("Masukkan nilai matriks A\n");
      for(i=0;i<2;i++)
            for(j=0;j<2;j++)
            {
                 printf(" A[%d][%d]:",i,j); scanf("%d",&A[i][j]);
                 //printf(%5d",x[i][j]);
            }
            printf("Masukkan nilai matriks B\n");
      for(i=0;i<2;i++)
            for(j=0;j<2;j++)
            {
                 printf(" B[%d][%d]:",i,j); scanf("%d",&B[i][j]);
            }
            printf("\n");
            printf("A=[%d %d]\n",A[0][0],A[0][1]);
            printf("  [%d %d]\n",A[1][0],A[1][1]);
            printf("\n");
            printf("B=[%d %d]\n",B[0][0],B[0][1]);
            printf("  [%d %d]\n\n",B[1][0],B[1][1]);
            printf("Penjumlahan matriks A + matriks B = matriks C\n\n");
            printf("C[%d+%d] [%d+%d]\n",A[0][0],B[0][0],A[0][1],B[0][1]);
            printf(" [%d+%d] [%d+%d]\n",A[1][0],B[1][0],A[1][1],B[1][1]);
            printf("\n");
            printf("C=[%d %d]\n",A[0][0]+B[0][0],A[0][1]+B[0][1]);
            printf("  [%d %d]\n",A[1][0]+B[1][0],A[1][1]+B[1][1]);
            printf("\n");
            printf("Perkalian matriks A * matriks B = matriks C\n\n");
            printf("C[%d*%d+%d*%d] [%d*%d+%d*%d]\n",A[0][0],B[0][0],A[1][0],B[0][1],A[0][1],B[0][0],A[1][1],B[0][1]);
            printf(" [%d*%d+%d*%d] [%d*%d+%d*%d]\n",A[0][0],B[1][0],A[1][0],B[1][1],A[0][1],B[1][0],A[1][1],B[1][1]);
            printf("\n");
            printf("C=[%d %d]\n",A[0][0]*B[0][0]+A[1][0]*B[0][1],A[0][1]*B[0][0]+A[1][1]*B[0][1]);
            printf("  [%d %d]\n",A[0][0]*B[1][0]+A[1][0]*B[1][1],A[0][1]*B[1][0]+A[1][1]*B[1][1]);
            printf("\n");
    system("pause");
    return(0);
}

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More