WAP to accept numbers from user for two, 2D arrays and display the contents of both and also display subtraction of both.


Comments

  1. #include
    void main()
    {
    int a[2][2],b[2][2],c[2][2],i,j;
    printf("enter element for 2*2 matrix a\n ");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    printf("enter element for2*2 matrix b\n");
    for(i=0;i<2;i++)


    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&b[i][j]);
    }
    }
    printf("subtraction of two matrix\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)

    {
    c[i][j]=a[i][j]-b[i][j];

    printf("%d\n",c[i][j]);
    printf("\t");
    }
    printf("\n");
    }
    }

    ReplyDelete
  2. #include
    void main()
    {
    int a[2][2],b[2][2],c[2][2],i,j;
    printf("enter element for 2*2 matrix a\n ");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    printf("enter element for2*2 matrix b\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&b[i][j]);
    }
    }
    printf("subtraction of two matrix\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)

    {
    c[i][j]=a[i][j]-b[i][j];

    printf("%d\n",c[i][j]);
    printf("\t");
    }
    printf("\n");
    }
    }

    ReplyDelete
  3. #include
    void main()
    {
    int a[2][2],b[2][2],c[2][2],i,j;
    printf("enter element for 2*2 matrix a\n ");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    printf("enter element for2*2 matrix b\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&b[i][j]);
    }
    }
    printf("subtraction of two matrix\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)

    {
    c[i][j]=a[i][j]-b[i][j];

    printf("%d\n",c[i][j]);
    printf("\t");
    }
    printf("\n");
    }
    }

    ReplyDelete
  4. #include

    int main() {
    int i, j, mat1[10][10], mat2[10][10], mat3[10][10];
    int row1, col1, row2, col2;

    printf("\nEnter the number of Rows of Mat1 : ");
    scanf("%d", &row1);
    printf("\nEnter the number of Cols of Mat1 : ");
    scanf("%d", &col1);

    printf("\nEnter the number of Rows of Mat2 : ");
    scanf("%d", &row2);
    printf("\nEnter the number of Columns of Mat2 : ");
    scanf("%d", &col2);



    for (i = 0; i < row1; i++) {
    for (j = 0; j < col1; j++) {
    printf("Enter the Element a[%d][%d] : ", i, j);
    scanf("%d", &mat1[i][j]);
    }
    }


    for (i = 0; i < row2; i++)
    for (j = 0; j < col2; j++) {
    printf("Enter the Element b[%d][%d] : ", i, j);
    scanf("%d", &mat2[i][j]);
    }


    for (i = 0; i < row1; i++)
    for (j = 0; j < col1; j++) {
    mat3[i][j] = mat1[i][j] - mat2[i][j];
    }


    printf("\nThe Subtraction of two Matrices is : \n");
    for (i = 0; i < row1; i++) {
    for (j = 0; j < col1; j++) {
    printf("%d\t", mat3[i][j]);
    }
    printf("\n");
    }


    }

    ReplyDelete
  5. #include
    void main()
    {
    int a[2][2],b[2][2],c[2][2],i,j;
    printf("enter element for 2*2 matrix a\n ");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    printf("enter element for2*2 matrix b\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&b[i][j]);
    }
    }
    printf("subtraction of two matrix\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)

    {
    c[i][j]=a[i][j]-b[i][j];

    printf("%d\n",c[i][j]);
    printf("\t");
    }
    printf("\n");
    }
    }

    ReplyDelete
  6. #include
    void main()
    {
    int a[2][2],b[2][2],c[2][2],i,j;
    printf("enter element for 2*2 matrix a\n ");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    printf("enter element for2*2 matrix b\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)
    {
    scanf("%d",&b[i][j]);
    }
    }
    printf("subtraction of two matrix\n");
    for(i=0;i<2;i++)
    {
    for(j=0;j<2;j++)

    {
    c[i][j]=a[i][j]-b[i][j];

    printf("%d\n",c[i][j]);
    printf("\t");
    }
    printf("\n");
    }
    }

    ReplyDelete

Post a Comment