addition of two matrices

2
This program let you to add two matrices of same size and displaying the elements of resultant matrix. void main() { int a[2][2], b[2][2], c[2][2]; printf("enter the elements of matrix a\n"); for(i=0 ; i<=1 ; i++) { for(j=0 ; j<=1 ; j++) { scanf("%d",&a[i][j]); } } printf("enter the elements of matrix b\n"); for(i=0 ; i<=1 ; i++) { for(j=0 ; j<=1 ; j++) { scanf("%d",&b[i][j]); } } printf("the sum of two matrices is \n"); for(i=0 ; i<=1 ; i++) { for(j=0 ; j<=1 ; j++) { printf("%d\n",a[i][j] + b[i][j]); } } } output

Upload: a-a

Post on 19-Aug-2015

46 views

Category:

Education


5 download

TRANSCRIPT

Page 1: addition of two matrices

This program let you to add two matrices of same size and displaying the elements of resultant matrix.

void main(){    int a[2][2], b[2][2], c[2][2];      printf("enter the elements of matrix a\n");   for(i=0 ; i<=1 ; i++)   {      for(j=0 ; j<=1 ; j++)      {            scanf("%d",&a[i][j]);        }    }

   printf("enter the elements of matrix b\n");   for(i=0 ; i<=1 ; i++)   {      for(j=0 ; j<=1 ; j++)      {            scanf("%d",&b[i][j]);        }    }

   printf("the sum of two matrices is \n");    for(i=0 ; i<=1 ; i++)   {      for(j=0 ; j<=1 ; j++)      {            printf("%d\n",a[i][j] + b[i][j]);        }    }}output

enter the elements of matrix a123

Page 2: addition of two matrices

4enter the elements of matrix b1234the sum of two matrices is 2468