Design a method addMatrix to add two matrices The header of

Design a method addMatrix to add two matrices. The header of the method is public [][] addMatrix(double [][] a, double [][] b) A + B = [a_11 a_12....a_1n a_21 a_22....a_2n a_m1 a_m2 a_mn] + [b_11 b_12.....b_1n b_21 b_22...b_2n b_m1 b_m2...b_mn] = [a_11 + b_11 a_12 + b_12...a_1n + b_1n a_21 + b_21 a_22 + b_22...a_2n + b_2n a_m1 + b_m1 a_m2 + b_m2...a_mn + b_mn]

Solution

#include<stdio.h>

void main()

{

Double a[4][4], b[4][4] , result[4][4] ;

Int i, j ;

printf(\"The resultant matrix is :\ \") ;

for(i = 0; i < 4 ; i++ ;)

{

for(j = 0 ; j < 4 ; j++ ;)

{

result[i][j] = a[i][j] + b[i][j] ;

printf(\"%lf\\t\",result[i][j]) ;

}

printf(\"\ \") ;

}

return 0 ;

}

 Design a method addMatrix to add two matrices. The header of the method is public [][] addMatrix(double [][] a, double [][] b) A + B = [a_11 a_12....a_1n a_21

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site