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>
#include< conio.h>

int main()
{
        //fill your code
        int m, n;
        int i, j;
         int mat1[10][10], mat2[10][10], mat3[10][10] ,mat4[10][10];

printf("Enter matrix size :");
scanf(“%d %d”,&m,&n);


printf("Enter matrix 1 values  :");
for(i = 0; i < m; i++)
{

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

printf("Enter matrix 2 values  :");
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 \t “, 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 \t “, mat4[i][j]);
    printf(“\n”);
}

getch();
}