hi, the guestion says "find the product of the numbers which are placed above the main diagonal and below the secondary diagonal AT THE SAME TIME." (i think it's (arr[1][3]) * (arr[2][3]) i my case, right?)
i'm confused as to how you correctly intup the array from the keyboard; and also if thats the right way to write this code
sure, you can input this way. I would print which location you are on each time on line 17, eg
4x4: row: "<< i <<"column: "<< j << endl; (whatever that is in your language)
0 1 2 3
4 5 6 7
8 9 0 1
2 3 4 5
the main diagonal is 0505
the one above that is 161
I am not sure what a 'side diagonal' is? Are you talking about the ones going up instead of down (I know them as 'secondary') ?
it would be 307 for example of one, but I do not know which.
so you have 2 ways to understand the question from here..
one loop that does both diagonals at once (which is silly because you can hard-code both, but whatever, you can iterate it)
or two threads that do them in parallel "at the same time".
so you need something like
product1 = product2 = 1;
for all the rows
product1 *= matrix[row][?]
product2 *= matrix[row][#]
where you need to figure out the correct indices to multiply based off what is asked.
note that not all rows will have a term; for example the diagonal above the primary only has 3 terms, not 4, so one of the row iterations should do nothing, use a condition to control this.
@jonnin thank you lots! sorry, the 'side diagonal' is 3692 from your matrix. so if i were to multiply the numbers that are above the main and below the 'side'(guessing it's called secondary) diagonals at the same time, then it'be 7*1
I don't know where you got 7*1. But I think you see what to do... locate the cells you need to multiply together in a loop and do so...
secondary diagonals go Up instead of Down, eg 2963 etc, from left to right. you gave right to left, going down. I have no idea what the official name of that is (if not "side"), or what it might be good for (apart from computing determinants the hard way). Ill have to review that... things I don't use fade quickly these days.