bigskinny1989 0 Newbie Poster

This is the problem i have to do:
Use a 3 x 4 matrix (i.e., a two-dimensional array with 3 rows and 4 columns). Each row contains the 3 coefficients of an equation and the solution. For example, in the equations given in the book:

3x + 2y - z = 10, -x + 3y +2z = 5, x - y - z = -1

the matrix will look like:

3 2 -1 10

-1 3 2 5

1 -1 -1 -1

Use the Gaussian elimination method described in the book. You should use at least two separate matrices to store the results of the various steps. Retain the original equations in one of the matrices.

Your program will have to work for any system of 3 equations with 3 unknowns. It must ask the user to input in the coefficients and solutions. The output will be something along the lines of: The solution is: x = -2, y = 5, z = -6

and i got this much so far but i don't know what to do now.

/* 2d array */

#include <iostream>
#include <cmath> 


using namespace std;
const int rows (3), cols (4);

int main ()
{
    double A [rows][cols], B[rows][cols], C[rows][cols]; 
         for ( int i=0, i<3, i++)
         {
             cout<< " Enter first coefficient of eq. 1"
                 << i+1;
             cin>> A[i][0];
             cout<< " Enter second coefficent of eq. 1"
                 << i+1;
             cin>> A[i][1];
             cout<< " Enter solution to eq. 1"
                 <<i=1
             cin>> A[i][2];
             {
                 for ( int j=0, j<3, j++)
                 {
                     cout<< " Enter coefficient"
                         << j+1<< "of equation"<< i+1;
                     cin>> A[i][j];
                 }
                      cout<< " Enter solution of equation"<< i+1;
                      cin>> A[i][3];
             }


                 multipler = -A[0][0] / A[1][0]
                 for (i=0; i<4, i++)
                     B[1][i]= multipler * A[1][i];
                 
                 multiipler= A[0][0] / A[2][0];
                 for (i=0; i<4, i++)
                     B[2][i]= multipler * A[2][i];
                
                 multiipler= A[0][0] / A[3][0];
                 for (i=0; i<4, i++)
                     B[3][i]= multipler * A[3][i];
                 
                 
                 return 0;

             

         }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.