title: To find determinant of a 3*3 matrix in c++
body: <p>hi guys I wanted to find determinant of a 3X3 matrix using c++ I wrote the following code but its not working. Can someone please point out the bug?
  Thanks in advance</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  #include&lt;fstream&gt;
  
  using namespace std;
  #define R 3
  
  int main(){
      fstream f;
      int x=1;
      f.open("values");//open the file that contains the matrix
      int** A;
      A=new int*[R];
      for(int i=0;i&lt;R;i++){
          A[i]=new int[R];
      }
      for(int i=0;i&lt;R;i++){
          for(int j=0;j&lt;R;j++){
              f&gt;&gt;A[i][j];//input values
          }
      }
      for(int i=0;i&lt;R;i++){
          x=x*A[i][i];
          for(int j=0;j&lt;R;j++){   
              if(A[i][i]!=0){A[i][j]=A[i][j]/A[i][i];}//using Gauss Jordan Elimination method
          }
          for(int k=i+1;k&lt;R;k++){//going at the next row...basically sweeping a column
              for(int y=i;y&lt;R;y++){
                  A[k][y]=A[k][y]-(A[k][i]*A[i][y]);//sweeping
              }           
          }
      }
      f.close();
      int z=1;
      for(int i=0;i&lt;R;i++){
          z=z*A[i][i];//in case all a[i][i] are zero z will be zero and hence the answer
      }
      cout&lt;&lt;"The det  is"&lt;&lt;endl&lt;&lt;x*z&lt;&lt;endl;
      return 0;
  }
  </code></pre>