BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

10.write a C Program to perform addition and subtraction of Matrices

 
  


/*10.write a C Program to perform addition and subtraction of Matrices*/


#include < stdio.h>
int main()
{
        //fill your code
        int m, n;
        int i, j;
         int mat1[m][n], mat2[m][n], mat3[m][n] ,mat4[m][n];


scanf(“%d %d”,&m,&n);

for(i = 0; i < m; i++)
{
for(j = 0; j < n; j++)
    scanf(“%d”,&mat1[i][j]);
}
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
    scanf(“%d”,&mat2[i][j]);
}



for(i = 0; i < m; i++)
{
    for(j = 0; j < n; j++)
    {
        mat3[i][j] = mat1[i][j] + mat2[i][j];
    }
}

printf("\n addition of matrics\n");

for(i = 0; i < m; i++)
{
    for(j = 0; j < n; j++)
    printf(“%d “, mat3[i][j]);
    printf(“\n”);
}






for(i = 0; i < m; i++)
{
    for(j = 0; j < n; j++)
    {
        mat4[i][j] = mat1[i][j] - mat2[i][j];
    }
}

printf("\n subtraction of matrics\n");

for(i = 0; i < m; i++)
{
    for(j = 0; j < n; j++)
    printf(“%d “, mat4[i][j]);
    printf(“\n”);
}

return 0;
}