fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. #define NCOL1 2
  4. #define NCOL2 2
  5. #define NROW1 2
  6. #define NROW2 2
  7. #define NCOL3 2
  8. #define NROW3 2
  9. double arrsum[NCOL3][NROW3];
  10. int main(void)
  11. {
  12. int i,j;
  13. void addarray(double a,double b);
  14. double ans;
  15. double arr1[NCOL1][NROW1], arr2[NCOL2][NROW1];
  16. printf("Please enter numbers for Matrix 1 :\n ");
  17. for(i=0;i<NCOL1;i++){
  18. for(j=0;j<NROW1;j++){
  19. printf("Please Enter for arr1[%i][%i]\n",i,j);
  20. scanf("%lf",&arr1[i][j]);
  21. printf("arr1[%i][%i]:%lf\n",i,j,arr1[i][j]);
  22. }
  23. }
  24. printf("Please enter numbers for Matrix 2 :\n ");
  25. for(i=0;i<NCOL2;i++){
  26. for(j=0;j<NROW2;j++){
  27. printf("Please Enter for arr2[%i][%i]\n",i,j);
  28. scanf("%lf",&arr2[i][j]);
  29. printf("arr2[%i][%i]:%lf\n",i,j,arr2[i][j]);
  30. }
  31. }
  32. for(i=0;i<NCOL3;i++){
  33. for(j=0;j<NROW3;j++){
  34. printf("%lf %lf\n",arr1[i][j],arr2[i][j]);
  35. addarray(arr1[i][j],arr2[i][j]);
  36. printf("%lf\n",ans);
  37. }
  38. }
  39. return 0;
  40. }
  41.  
  42. void addarray(double a,double b) {
  43. int i,j,c=a+b;
  44. for(i=0;i<NCOL3;i++){
  45. for(j=0;j<NROW3;j++){
  46. arrsum[i][j]=a+b;
  47. }
  48. }
  49. return c;
  50. }
Success #stdin #stdout 0.02s 1724KB
stdin
0
1
2
3
4
5
6
7
stdout
Please enter numbers for Matrix 1 :
 Please Enter for arr1[0][0]
arr1[0][0]:0.000000
Please Enter for arr1[0][1]
arr1[0][1]:1.000000
Please Enter for arr1[1][0]
arr1[1][0]:2.000000
Please Enter for arr1[1][1]
arr1[1][1]:3.000000
Please enter numbers for Matrix 2 :
 Please Enter for arr2[0][0]
arr2[0][0]:4.000000
Please Enter for arr2[0][1]
arr2[0][1]:5.000000
Please Enter for arr2[1][0]
arr2[1][0]:6.000000
Please Enter for arr2[1][1]
arr2[1][1]:7.000000
0.000000   4.000000
0.000000
1.000000   5.000000
0.000000
2.000000   6.000000
0.000000
3.000000   7.000000
0.000000