0
# include<iostream.h>
void main()

const int m=3;
const int n=4;
const int p=5; 
int A[m][n];
int B[n][p];
{

        cout<<"3x4 matrix";
        for(m=0; m<3; m++)
        {
            for(n=0; n<4; n++)
                cin>>A[m][n];
                cout<<A[m][n]<<"\t";
        }
        cout<<"\n";



        cout<<"4x5 matrix";
        for(n=0; n<3; n++)
        {
            for(p=0; p<5; p++)
                cin>>B[n][p];
                cout<<B[n][p]<<"\t";
        }
        cout<<"\n";


        int d, c=0;
        for(m=0; m<3; m++)
        {
            for(p=0; p<5; p++)
            {
                for(n=0; n<4; n++)
                d=A[m][n]*B[n][p];
                c=c+d;
            }
            cout<<c;
        }
        
}
2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by dilip.mathews
0
const int m=3;
const int n=4;
const int p=5; 
int A[m][n];
int B[n][p];

Put your initializations inside main if you are using it locally or above main(global usage) if it is used in more than one function

for(m=0; m<3; m++)

This will create problems for you as you have declared m as const. Same with n and p.

In this case use different variables for declaring array and indexing thru the array.

int A[m][n];
int B[n][p];

If you are declaring array like this then m, n, and p must be constant

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.