Posts

Showing posts with the label matrix multiplication

Matrix Program #2

Image
9. Read two matrices, first m x n and second n x t, perform multiplication operation and store result in third matrix and print it. #include<stdio.h> void main() {    int i, j,k, mat1[10][10], mat2[10][10], mat3[10][10];    int row1, col1, row2, col2,sum=0;    printf("Enter the number of Rows of Mat1 : ");    scanf("%d", &row1);    printf("Enter the number of Columns of Mat1 : ");    scanf("%d", &col1);    printf("Enter the number of Rows of Mat2 : ");    scanf("%d", &row2);    printf("Enter the number of Columns of Mat2 : ");    scanf("%d", &col2);    /* Before accepting the Elements Check if no of      columns of matrix 1 and rows of martix 2 is equal */     if(col1!=row2)      {           printf("\nOrder of two matrices is not same...

Matrix Program #1

Image
8. Read two n x n matrices and perform addition of matrices into third matrix and print it. #include<stdio.h> void main() {    int i, j, mat1[10][10], mat2[10][10], mat3[10][10];    int row1, col1, row2, col2;    printf("Enter the number of Rows of Mat1 : ");    scanf("%d", &row1);    printf("Enter the number of Columns of Mat1 : ");    scanf("%d", &col1);    printf("Enter the number of Rows of Mat2 : ");    scanf("%d", &row2);    printf("Enter the number of Columns of Mat2 : ");    scanf("%d", &col2);    /* Before accepting the Elements Check if no of     rows and columns of both matrices is equal */    if (row1 != row2 || col1 != col2)    {       printf("\nOrder of two matrices is not same\n");       return ;    }   printf("\n"); ...