C ++ homework help


Find the product of two matrices, a (3x3) and b (3x3), where the user enters the values, and find the determinant of the c matrix to be obtained and write the c++ code on the screen.
a) c = a * b
b) Result = det (c)
please help form me :)
Our help is dependent on you posting some actual effort towards solving your own problem.

Just dumping your assignment and expecting a full working answer isn't going to happen.

http://www.catb.org/esr/faqs/smart-questions.html#homework
sorry man but i couldn't understand this assignment so i wrote it directly
sorry :)
and my english is a little bit troubled
https://www.mathsisfun.com/algebra/matrix-multiplying.html
https://www.chilimath.com/lessons/advanced-algebra/determinant-3x3-matrix/

Can you write code to find the determinant of a 2x2 matrix?
 [ a b; 
   c d ]

e.g. double det2x2(double a, double b, double c, double d) { ... }
Last edited on
Hi,

I did this a while back. My approach was to do the following

1. Declare 2 matrices as 2d arrays (usually something like double A[3][3] = (0, 0.....9 elements in total seperated by commas)
2.Declare 2 other arrays to assign the calculated values to (like above)
3. Code a function to work out the product and assign it to the extra arrays you've made(usually this is 2 nested for loops)

1
2
3
4
5
6
7
for (int i = 0; i < 3; i++)
{  //(this goes to the row)  
    for (int j = 0; j < 3; j++)
    {
    // do your stuff to each element of the array
    }
}


4. Call the function
5. Display the array to check the values. (using 2 nested for loops, one for rows and the other for the columns and the cout command)

For the determinant, there is a formula you can use for working out the determinant of a 3 x 3 array. So you could just make the function to do this all in one go. But in reality, all the formula uses is working out the 2x2 determinant and multiplying it out with the corresponding minors.
I have actually done this very questions. But I will not share it with you as the other guys are right, make the effort to code some of it yourself, make some mistakes and then move on from them. But once you dedicate the time to it, it's really rewarding. Keep it up!
I want this help for my friend, he has been trying to do it for days, but he can't do it. When he sees the solution, he can understand most things.Therefore ı directly entered to subject. Again sorry
I don't know what you're apologizing for, we're just saying to be more specific if you want help.
In order to take the det of 3x3 matrix, you're going to need to know how to take the det of a 2x2 matrix, which is much easier, so break your problem into smaller pieces.

For matrix multiplication, you multiply each element of the i'th row by each element of the j'th column to get the value of the {i,j} cell of the multiplied matrix. Try writing a for loop to do this, like what Shishykish showed.
e.g. for a 2x2, it's
[ a, b ;    *  [ e, f ;      = [  a * e + b * g,  a * f + b * h ;
  c, d ]         g, h ]           c * e + d * g,  c * f + d * h ]
Last edited on
Registered users can post here. Sign in or register to post.