Search This Blog

Loading...

Write a program to read two 5 X 5 matrices from the user and store the Addition of two matrices in the resultant matrix. i.e. C=A + B , where A,B,C each one is 5 X 5 Matrix. : GTU Nov-Dec 2010

#include<stdio.h>
#include<conio.h>

main()
{
    int A[5][5],B[5][5],C[5][5],i,j;
    clrscr();

    printf("\n\n Please Enter First Matrix's Element : \n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("\nA[%d][%d] = ",i,j);
            scanf("%d",&A[i][j]);
        }
    }

    printf("\n\n Please Enter Second Matrix's Element : \n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("\nB[%d][%d] = ",i,j);
            scanf("%d",&B[i][j]);
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            C[i][j] = A[i][j] + B[i][j];
        }
    }

    printf("\n\n Sum of Two Matrix : \n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("%d ",C[i][j]);
        }
        printf("\n");
    }

    getch();
}

No comments:

Post a Comment