CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Junior Member
Join Date
Jan 2010
Posts
17

## Re: Adding Two-Dimensional arrays together

Oh yes I can calculate simultaneous equations by hand. I just found it difficult using a loop to attempt to calculate them with like addition. I just don't understand the whole calculation via a loop with a 2D Array of [3] [4]. I'm a total noob at C++. I've tried an attempt and to me it doesn't seem correct.

2. Elite Member Power Poster
Join Date
Oct 2007
Location
Seattle, WA
Posts
10,895

## Re: Adding Two-Dimensional arrays together

Please, lay out the sequence of steps you'd use to solve this pair of equations, and we'll go from there.

9 = 4x + 6y
-3 = x - 10y

3. Elite Member Power Poster
Join Date
Apr 1999
Posts
27,449

## Re: Adding Two-Dimensional arrays together

Originally Posted by TBsparky
Oh yes I can calculate simultaneous equations by hand.
The issue is how you are solving these by hand. If you're solving them by hand using the algrebaic way of doing things, you will be here for months writing a program to simulate what you learned in junior high school. Heck, an expert would be here for weeks writing such a program.

The easiest way that simultaneous equations are solved by computer is to use Gaussian elimination. Did your teacher discuss that? If not, please look that up, as you cannot possibly write a program to solve equations in the "traditional" math book way.

Regards,

Paul McKenzie

4. Junior Member
Join Date
Jan 2010
Posts
17

## Re: Adding Two-Dimensional arrays together

No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices

5. Elite Member Power Poster
Join Date
Oct 2007
Location
Seattle, WA
Posts
10,895

## Re: Adding Two-Dimensional arrays together

Originally Posted by TBsparky
by the use of matrices
Key phrase. Do you know what this means? "use of matrices" can mean anything.

6. Elite Member Power Poster
Join Date
Apr 1999
Posts
27,449

## Re: Adding Two-Dimensional arrays together

Originally Posted by TBsparky
No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices
And Guassian method uses matrices.

Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math. The routine you want is called Guassian elimination. Just do a google search, and you will see the routine explained to you.

If your teacher wants you to solve equations as you do with traditional math you learned in school, he or she is playing a very cruel joke on you. You won't, and I bet your entire class won't be able to complete the assignment, or even know where to start if that is really what the teacher is expecting. So I'm assuming your teacher is wanting you to solve the equations using Gaussian elimination (there are other methods, but this is the easiest to implement).

Edit:

http://www.codeguru.com/forum/showth...light=gaussian

Regards,

Paul McKenzie
Last edited by Paul McKenzie; April 28th, 2011 at 04:49 PM.

7. Elite Member Power Poster
Join Date
Oct 2007
Location
Seattle, WA
Posts
10,895

## Re: Adding Two-Dimensional arrays together

Originally Posted by Paul McKenzie
Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math.
You can actually, for this specific case: 2 equations in 2 unknowns. It's simple enough in that case to write out the substitutions explicitly.

Gaussian elimination is the more general solution for handling n equations in n unknowns, of course.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•