# help...2 C++ problems

Printable View

• 04-29-2006
mr_god_god
help...2 C++ problems
(I deleted the whole program because I don't want my school mates to copy it, anyway, sorry for the inconvenience)
These two programs are the homework i needed to do. I had been figuring it out for two weeks. But my mind still seems to be stuck.

The aim of this program is to solve a twoXtwo matrix (just a twoXtwo). I had successfully used another method to finish it before. But the homework requires me to bring in a inverseArray to save the values of the changed array

PHP Code:

``` void multiplyMatrices(double inverseArray[][2],double multArray[],double oneOverA) {     multArray[0]=inverseArray[0][0]*inverseArray[2][0]+inverseArray[0][1]*inverseArray[2][1]*oneOverA;     multArray[1]=inverseArray[1][0]*inverseArray[2][0]+inverseArray[1][1]*inverseArray[2][1]*oneOverA; }  ```
I think the problem seems to be that inverseArray is changed after saving the array. But just don't know what to do with it.

The techniques that are allowed are arrays and the stuff before that. I know I really suck in C++, please help me if anyone knows the solution. Thank you so much.
• 04-29-2006
Daved
>> if(chr!='y'||chr!='Y'||chr!='n'||chr!='N')
Follow that logic and you will see that it always evaluates to true. If the character does not equal 'y', or if it doesn't equal 'Y', etc. Every character either doesn't equal 'y' or doesn't equal 'Y'. You are looking only for characters that don't equal 'y' and don't equal 'Y'.
• 04-29-2006
mr_god_god
Thank you so much, I solved the second program.
But how about the first one?
• 04-29-2006
Daved
Code:

```    double array[][2]={0};     double inverseArray[][2]={0};     double multArray[]={0};```
You need to set the size for these arrays when you declare them. I doubt that's the issue, but it should still be done. Also, why does your input loop have 3 values for i (0 to 2) where the rest of the code seems to assume only 2 values (0 and 1)?
• 04-30-2006
mr_god_god
Thank you so much again, you are right, I solved the program.

For your question, the input loop prompts the user to enter values A,B,C,D,E,F:
Code:

```cout<<"A(x1)+B(x2)=E"<<endl; cout<<"C(x1)+D(x2)=F"<<endl<<endl;```
Sorry for the rest of your questions, I don't really understand what you mean. Can you rephrase it?

And can you please tell me how come I have to do so?
(p.s. My teacher taught me this would work)
• 04-30-2006
Daved
I'm not sure which of my questions you didn't understand, and now that the code is gone I don't remember exactly what I meant. Basically, you can specify a function parameter as double array[][2], but you can't specify the actual declaration of an array that way because there is no size for the first dimension. The function parameter works because the compiler doesn't care what the size is as an array parameter just points to an existing array. When you actually declare an array, though, the compiler needs the size so that it can create the memory for it. So I would use double array[2][2] or double array[3][2] depending on which one you actually wanted.
• 05-01-2006
mr_god_god
I am sorry, but thanks again