Calculating the determinants of data entered This program is supposed to calculate the determinants of the data entered. I believe it does. Within the guidelines of this exercise we were not to break this down to functions but all out of main. We will be breaking it down into functions in part a and b of this overall exercise.

However, I don't know enough about matrices and determinants yet to know if I am using the equation given to me correctly. I know this out puts the data given to the screen correctly and the formula given was:

determinant = (AEI) + (BFG) + (CDH) - (BDI) - (AFH) - (CEG)


which equates to the array elements:

00 * 11 * 22 + 01 * 12 * 20 + 02 * 10 * 21- 01 * 10 * 22 - 00 * 12 * 21 - 02 * 11 * 20


Given the 3x3 block where the first row is ABC, second row of DEF and third row of GHI.

I am asking that it be analyzed and critiqued.

# include &lt;iostream&gt;
# include &lt;stdio.h&gt;
# include &lt;iomanip&gt;

using namespace std;

int main()
{
    int x,y,z,;
    char ch;
    float  My3DMatrix[3][3];
    int mReader[9];
    for (x = 0 ; x &lt;= 8 ; x++)//This array is for accessing the Matrix elements in
    {                     //the prescribed manner to calculate the determ.
        y = x;
        if( x == 3 || x == 8 )y = 1;
        if(x == 4 || x ==6 )y = 2;
        if(x == 5 || x == 7 )y = 0;
        mReader[x] = y;
    }
    do  //This initiates the main loop
    {
        cout&lt;&lt;"Calculation of  3 x 3 Determinant"&lt;&lt;endl&lt;&lt;endl;
        for(x = 0; x&lt;=2 ;x++) // This loop querries the user for 
        {                     //input and feeds the My3DMatrix
            cout&lt;&lt;"What is row "&lt;&lt;x+1&lt;&lt;" of the matrix? ";
            for (y = 0 ; y &lt;=2 ; y++)
            {
                cin&gt;&gt;My3DMatrix[x][y];
            }   //The matrix is now fed
        }
        cout&lt;&lt;"\nThe 3 x 3 Matrix entered is: "&lt;&lt;endl; //Now the Raw
        cout&lt;&lt;setprecision(3)&lt;&lt;fixed; //Matrix data is displayed
        for(x = 0 ; x&lt;=2 ; x++)
        {
            cout&lt;&lt;My3DMatrix[x][0]&lt;&lt;"\t"&lt;&lt;My3DMatrix[x][1]&lt;&lt;"\t"
                &lt;&lt;My3DMatrix[x][2]&lt;&lt;endl;
        }
        float Determinant[6]; //This array is for storing the 6
        y = -1 ; z = 0; //products from each row of the matrix
        for(x = 0 ; x &lt;= 8 ; x++)// There are 9 indexes to create 3 products from
        {   //This loop pulls the correct indexes from My3DMatrix then  creates
            if (z&gt;=3) z = 0; //and stores the products into Determinant[x] 0 - 2
            if ((x % 3) == 0 || x == 0)
            {
                y = y + 1;
                Determinant[y] = 1;
            }
            Determinant[y] =  Determinant[y] * My3DMatrix[z][mReader[x]];
            z = z + 1;
        }
        y = 2 ; z = 0;
        for(x = 9 ; x &gt;= 1 ; x--)// There are 9 indexes to create 3 products from
        {       //This loop pulls the correct indexes from My3DMatrix then creates
            if (z&gt;=3) z = 0;//and stores the products into Determinant[x] 3 - 5
            if ((x % 3) == 0 || x == 0)
            {
                y = y + 1;
                Determinant[y] = 1;
            }
            Determinant[y] =  Determinant[y] * My3DMatrix[z][mReader[x - 1]];
            z = z + 1;
        }
        float myAnswer;
        myAnswer = 0;//Here with Determinant[6] loaded with the correct index products:
        myAnswer = Determinant[0] + Determinant[1] + Determinant[2] ; //The deternm.
        myAnswer = myAnswer -  Determinant[3] - Determinant[4] - Determinant[5]; //and simple calculation is plain 
            cout&lt;&lt;"The determinant of the above matrix is: "&lt;&lt; myAnswer&lt;&lt; endl;
        cout&lt;&lt;"Would you like to Do another Matrix (Y/N)? ";

        cin&gt;&gt;ch ;
    }while(ch == 'Y' || ch == 'y');

    cin.get();

    return 0;
}
General comments:

Use one line per variable.

int x,y,z,;


Prefer to use smaller than than smaller than or equal. This is a bit nit-picky but when working with array bounds you can then use the same number in the test as in the size of the array, which makes it slightly easier to read.

int mReader[9];
for (x = 0 ; x &lt;= 8 ; x++)

// try
int mReader[9];
for (x = 0 ; x &lt; 9 ; x++) // easy to see correlation between x and mReader


The variables x/y/z are not used to pass information between different loops. So rather than declare them at the top declare them as close to the point of use as possible. Your loops should look more like this:

for(int x = 0; x&lt;=2 ;x++)
 // ^^^ x is local to the loop


Do not fall in to the mental trap of thinking that you are saving space for re-use. The compiler is quite capable of doing that all by itself.

This test seems a bit redundant:

if ((x % 3) == 0 || x == 0)
     //          ^^^^^^^^^  Why? if x == 0 then (x % 3) == 0 thus the second part of the
     //                          test will never be evaluated.


Are you sure this is correct?

for(x = 9 ; x &gt;= 1 ; x--)


Seems like x never reaches 0. As it turns out it is correct even if it looks wrong. But you need to read the rest of the code to make sure it is being used correctly. Writing code were you need to scan ahead to determine correctness is not a good idea. I would loop the same way as all the other loops (using a different variable name) then adjust the usage.

for(int reverseX = 0 ; reverseX &lt; 9 ; ++reverseX)
{
 ..... 
     Determinant[y] =  Determinant[y] * My3DMatrix[z][mReader[9 - 1 - reverseX]];


Does this work?

cin.get();


Looks like you are trying to pause the application before termination. But to me it looks like it will try and swallow the '\n' from the last time you hit enter, and thus do nothing.