Sunday 7 September 2014

determinant

matrix multiplication

#include <stdio.h>
void main()
{
    int m[3][3], n[3][3], i, j, h[9];
    printf("please enter the elements of matrix A\n");
     for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
        {
            printf("enter the element a(%d,%d)", i + 1, j + 1);
            scanf("%d", &m[i][j]);
        }
        printf("entered matrix\n");
        for (i=0;i<3;i++)
        {
            for (j=0;j<3;j++)
            {
            printf("%d\t",m[i][j]);
            }
            printf("\n");
        }
               
    printf("enter the elements of matrix B \n");
    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
        {
            printf("enter the elements of b(%d,%d)", i + 1, j + 1);
            scanf("%d", &n[i][j]);
        }
        printf("entered matrix\n");
        for (i=0;i<3;i++)
        {
            for (j=0;j<3;j++)
            {
                printf("%d\t",n[i][j]);
            }
            printf("\n");
        }
        printf("\n\n\n");
h[0]=m[0][0]*n[0][0]+m[0][1]*n[1][0]+m[0][2]*n[2][0];
h[1]=m[0][0]*n[0][1]+m[0][1]*n[1][1]+m[0][2]*n[2][1];
h[2]=m[0][0]*n[0][2]+m[0][1]*n[1][2]+m[0][2]*n[2][2];
h[3]=m[1][0]*n[0][0]+m[1][1]*n[1][0]+m[1][2]*n[2][0];
h[4]=m[1][0]*n[0][1]+m[1][1]*n[1][1]+m[1][2]*n[2][1];
h[5]=m[1][0]*n[0][2]+m[1][1]*n[1][2]+m[1][2]*n[2][2];
h[6]=m[2][0]*n[0][0]+m[2][1]*n[1][0]+m[2][2]*n[2][0];
h[7]=m[2][0]*n[0][1]+m[2][1]*n[1][1]+m[2][2]*n[2][1];
h[8]=m[2][0]*n[0][2]+m[2][1]*n[1][2]+m[2][2]*n[2][2];
printf("the multiplication is…………\n");
printf("%d\t%d\t%d\n ",h[0],h[1],h[2]);
printf("%d\t%d\t%d\n ",h[3],h[4],h[5]);
printf("%d\t%d\t%d  ",h[6],h[7],h[8]);
}