please help me out, i want a code of algo by i can find out the solution, i know hoe to multiply 2x2 or 3x3 matrices but i want user friendly code in which user can chose option. help me please its in my project.

Okay... first of all this forum really isn't for just giving away free code, so I doubt anybody will just give you the solution. Now, I assume you are familiar with c++, but judging by your question it is hard to tell. For instance, how are you storing your matrices? is it type matrix[width][height]? or maybe type matrix[width*height]? or could it be vector<vector<type>> matrix? We need more to go off of. On top of that, the way you asked the question makes me think that you haven't even tried to figure this one out yet. I assume you know how to multiply matrices, so try solving the most general case. IE: multiply

A B C ... X
D E F ... X
. .  .
. .     .
X X       X

where A,B,C... are just variables. With this matrix:

a b c ... x
d e f ... x
. .  .
. .     .
x x       x

While you are doing this think of what the constraints might be? Once you can solve the problem on paper, then you are ready to program it.

As for making the program user friendly, one thing that really helps with that is proper modularization in the code. You should break your code up into as many functions as makes sense. If any function does more than 1 distinct things, it should really be broken up into two things. EG:

int f(int a, int b)
{
    return a+a*b;
}
//should become:
int add(int a, int b)
{
    return a+b;
}
int mul(int a, int b)
{
    return a*b;
}
int f(int a, int b)
{
    int ret=mul(a,b);
    return add(a,ret);
}

Obviously that is a silly code snippet, but it makes the point. Making functions then encourages you to basically make menus where the user just picks what function will be called. Typically you have them input a character to represent what they want to do (or a number if you prefer) then you use a switch statement to call the appropriate function.

Good Luck.

Do you mean you want to multiply A-matrix by B-matrix by C-matrix by D-matrix, etc.? You will have to do that one at a time.

Or do you mean you want the option of choosing among several different-sized matrices, but only two are going to be multiplied together?

Off the top of my head, I seem to recall that "Narue" posted a code block some time ago that did matrix multiplication. Just do a search of these forums.

This article has been dead for over six months. Start a new discussion instead.