Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program B,C,D please help im using DEV C++ Write a program that will calculate t

ID: 3683571 • Letter: P

Question

Program B,C,D please help im using DEV C++

Write a program that will calculate the determinant of a 3 by 3 matrix This program must have either three one dimensional floating point arrays with three elements each or one two dimensional array with 3 rows and 3 columns A 3 Times 3 array is show below. The determinant of the matrix would be calculated as follows determinant = (AEI) + (BFG) + (CDH) - (BDI) - (AFH) - (CEG) OR determinant = (r1c1*r2c2*r3c3) + (r1c2*r2c3*r3c1) + (r1c3*r2c1*r3c2) - (r1c2*r2c1*r3c3) - (r1c1*r2c3*r3c2) - (r1c3*r2c2*r3c1) In the main function read in the nine values, reprint the matrix and report the result, until no more are requested by answering N to the question. Two sample Matrix Inputs Row 1 1.00 3.00 4.00 or 1.00 1.00 0.00 Row 2 2.00 2.00 5.00 or 0.00 1.00 1.00 Row 3 3.00 1.00 6.00 or 1.00 0.00 1.00 Outputs for either Matrix Report of Matrix entered 1.000 3.000 4.000 or 1.000 1.000 0.000 2.000 2.000 5.000 or 0.000 1.000 1.000 3.000 1.000 6.000 or 1.000 0.000 1.000 Determinant 0.000 or Determinant 2.000 The program should look as follows: Calculation of 3Times 3 Determinant What is Row 1 of the matrix? 1 3 4 What is Row 2 of the matrix? 2 2 5 What is Row 3 of the matrix? 3 1 6 3 Times 3 Matrix entered is 1.000 3.000 4.000 2.000 2.000 5.000 3.000 1.000 6.000 The determinant of the above matrix is 0.000 Would you like to Do another Matrix (Y/N)? N Demonstrate to the instructor the successful completion of the program output. Have this sheet ready for instructor to sign. Hand to instructor to receive credit. Modify the above program to have three functions called from main() that do the following getArray() that passes the array/arrays to be changed such that it inputs the 9 values outArray() that passes the array/arrays to be output the 9 values such that the values CANNOT be changed by the function dtmntArray() will return the determinant calculated by passing the array/arrays that the values CANNOT be changed by the function Output a three dimensional floating point array 3 Times 3 Times 3 not initialized Output a three dimensional floating point array 3 Times 3 Times 3 initializing only one element

Explanation / Answer

//program B
#include <iostream>
#include<iomanip>
using namespace std;

main()
{
   int i,j;
   char ch;
   double matrix[3][3],determinant;

   cout<<" Calculation of 3X3 Determinant"<<endl;
   do
   {
   cout << "Enter the elements of 3X3 matrix ";
    for ( i = 0 ; i < 3 ; i++ )
   {
       cout<<" what are row "<<i+1<<" elements:";
      for ( j = 0 ; j < 3 ; j++ )
         cin >> matrix[i][j];
   }
   cout<<"3X3 matrix entered is:"<<endl;
   for ( i = 0 ; i < 3 ; i++ )
   {
         for ( j = 0 ; j < 3 ; j++ )
         std::cout<< " "<<std::setprecision(3)<<matrix[i][j];
         cout<<endl;
   }
   determinant=(matrix[0][0]*matrix[1][1]*matrix[2][2])
               +(matrix[0][1]*matrix[1][2]*matrix[2][0])
               +(matrix[0][2]*matrix[1][0]*matrix[2][1])
               -(matrix[0][1]*matrix[1][0]*matrix[2][2])
               -(matrix[0][0]*matrix[1][2]*matrix[2][1])
               -(matrix[0][2]*matrix[1][1]*matrix[2][0]);
   std::cout<<" The determinant of the above matrix is:"<<std::setprecision(3)<<determinant;
        cout<<"would you like to do another matrix(y/n)";
        cin>>ch;
        if(ch=='n')
        return 0;
}while(ch=='y');
         return 0;
}

what are row 3 elements:3       4       2                                                            

3X3 matrix entered is:                                                                               

        1       2       3                                                                            

        4       5       3                                                                            

        3       4       2                                                                            

                                                                                                     

The determinant of the above matrix is:3would you like to do another matrix(y/n)n                    

program C:

//program C
#include <iostream>
#include<iomanip>
using namespace std;
void getarray(double matrix[][3])
{
     int i,j;
for ( i = 0 ; i < 3 ; i++ )
   {
       cout<<" what are row "<<i+1<<" elements:";
      for ( j = 0 ; j < 3 ; j++ )
         cin >> matrix[i][j];
   }
}
void outarray(double matrix[][3])
{
     int i,j;
      for ( i = 0 ; i < 3 ; i++ )
   {
         for ( j = 0 ; j < 3 ; j++ )
         std::cout<< " "<<std::setprecision(3)<<matrix[i][j];
         cout<<endl;
   }
}
double dtmentArray(double matrix[][3])
{
double determinant=(matrix[0][0]*matrix[1][1]*matrix[2][2])
               +(matrix[0][1]*matrix[1][2]*matrix[2][0])
               +(matrix[0][2]*matrix[1][0]*matrix[2][1])
               -(matrix[0][1]*matrix[1][0]*matrix[2][2])
               -(matrix[0][0]*matrix[1][2]*matrix[2][1])
               -(matrix[0][2]*matrix[1][1]*matrix[2][0]);
               return determinant;
}
int main()
{
   int i,j;
   char ch;
   double matrix[3][3],determinant;

   cout<<" Calculation of 3X3 Determinant"<<endl;
   do
   {
   cout << "Enter the elements of 3X3 matrix ";
   getarray(matrix);
   cout<<"3X3 matrix entered is:"<<endl;
   outarray(matrix);
determinant=dtmentArray(matrix);

   std::cout<<" The determinant of the above matrix is:"<<std::setprecision(3)<<determinant;
        cout<<"would you like to do another matrix(y/n)";
        cin>>ch;
        if(ch=='n')
        return 0;
}while(ch=='y');
         return 0;
}

what are row 2 elements:5       4       3                                                            

                                                                                                     

what are row 3 elements:7       6       5                                                            

3X3 matrix entered is:                                                                               

        1       2       3                                                                            

        5       4       3                                                                            

        7       6       5                                                                            

                                                                                                     

The determinant of the above matrix is:0would you like to do another matrix(y/n)n      
program D;

1.printing matrix without initializing

#include<iomanip>
using namespace std;

main()
{
   int i,j;
   double matrix[3][3],determinant;
   for ( i = 0 ; i < 3 ; i++ )
   {
         for ( j = 0 ; j < 3 ; j++ )
         std::cout<< " "<<std::setprecision(3)<<matrix[i][j];
         cout<<endl;
   }
}

sh-4.3$ g++ -std=c++11 -o main *.cpp                                                                 

sh-4.3$ main                                                                                         

        5.61e-321       2.12e-314       6.95e-310                                                    

        2.07e-317       9.88e-324       2.07e-317                                                    

        2.07e-317       0       2.07e-317  

2.printing matrixt initializing only one element

#include <iostream>
#include<iomanip>
using namespace std;

main()
{
   int i,j;
   double matrix[3][3]={2.9},determinant;

   for ( i = 0 ; i < 3 ; i++ )
   {
         for ( j = 0 ; j < 3 ; j++ )
         std::cout<< " "<<std::setprecision(3)<<matrix[i][j];
         cout<<endl;
   }
}

sh-4.3$ g++ -std=c++11 -o main *.cpp                                                                 

sh-4.3$ main                                                                                         

        2.9     0       0                                                                            

        0       0       0                                                                            

        0       0       0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote