Penjumlahan 2 Matrik

#include
main()
{
    int a[2][3];
    int c,d;
    int b[2][3];
    int e,f;
    int g[2][3];
    int h,i;

    printf("Penjumlahan 2 Matrik"); printf("\n\n");


    {
        printf ("Bilangan Matriks A\n\n");
        for(c=0;c<=1;c++)
        {
            for(d=0;d<=2;d++)
            {
                printf(" Matrik A [%d,%d] = ",c,d);scanf("%d",&a[c][d]);
            }

        }
    printf ("\n Matriks A \n\n");
        for(c=0;c<=1;c++)
        {
            for(d=0;d<=2;d++)
            {
                printf(" %d ",a[c][d]);
            }
         printf("\n\n");
        }
    }
    printf ("\n");
    {
            printf ("Bilangan Matriks B\n\n");
            for(e=0;e<=1;e++)
        {
            for(f=0;f<=2;f++)
            {
                printf(" Matrik B [%d,%d] = ",e,f);scanf("%d",&b[e][f]);
            }

        }
    printf ("\n Matriks B \n\n");
        for(e=0;e<=1;e++)
        {
            for(f=0;f<=2;f++)
            {
                printf(" %d ",b[e][f]);
            }
         printf("\n\n");
        }
    }
    printf ("Hasil Matriks A + Matriks B \n\n");
        g[0][0]=a[0][0]+b[0][0]; g[0][1]=a[0][1]+b[0][1]; g[0][2]=a[0][2]+b[0][2];
        g[1][0]=a[1][0]+b[1][0]; g[1][1]=a[1][1]+b[1][1]; g[1][2]=a[1][2]+b[1][2];
        for(h=0;h<=1;h++)
        {
             for(i=0;i<=2;i++)
             {
                printf(" %d ",g[0][0],g[0][1],g[0][2]);
                printf(" %d ",g[1][0],g[1][1],g[1][2]);
             }
         printf("\n\n");
        }

}

Post a Comment

1. Jangan lupa tinggalkan Likenya ya
2. Berkomentarlah dengan baik dan sopan

[blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget