# 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;
        }
        
}

Recommended Answers

All 2 Replies

Can you explain the problem?????

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.