multiplying matrices w/ arrays

can someone please tell me what i am doing wrong i have stared at this code long enough. it works fine with integers but doubles give me overload. i know it is something simple at this point...just need another eye

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
void main()
{
  double a[3][3] , b[3][3] , c[3][3];

 int i , j , k;
  cout<<"Enter Matrix A";
  for( i = 0 ; i < 3 ; i++)
     for( j = 0 ; j < 3 ; j++)
        cin>>a[i][j];

  cout<<"Enter Matrix B";
  for( i = 0 ; i < 3 ; i++)
     for( j = 0 ; j < 3 ; j++)
        cin>>b[i][j];

  for( i = 0 ; i < 3 ; i++)
     for( j = 0 ; j < 3 ; j++)
     {
        c[i][j] = 0;
        for( k = 0 ;k < 3 ; k++)
           c[i][j] += a[i][k]*b[k][j];
     }
  cout<<"The resultant matrix is ";
  for( i = 0 ; i < 3 ; i++)
  {
     for( j = 0 ; j < 3 ; j++)
        cout<<c[i][j]<<" ";
     cout<<endl;
  }
  system("pause");
  
}
how is it not working?
and maybe some example-input would be nice
Topic archived. No new replies allowed.