1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Advocard [28]
2 years ago
13

g For this project you are required to perform Matrix operations (Addition, Subtraction and Multiplication). For each of the ope

rations mentioned above you have to make a function in addition to two other functions for ‘Inputting’ and ‘Displaying’ the Matrices in Row Order (rows are populated left to right, in sequence). In total there will be 5 functions: 3 for the operations and 2 functions for inputting and displaying the data.
Engineering
1 answer:
Kruka [31]2 years ago
5 0

Answer:

C++ code is explained below

Explanation:

#include<iostream>

using namespace std;

//Function Declarations

void add();

void sub();

void mul();

//Main Code Displays Menu And Take User Input

int main()

{

  int choice;

  cout << "\nMenu";

  cout << "\nChoice 1:addition";

  cout << "\nChoice 2:subtraction";

  cout << "\nChoice 3:multiplication";

  cout << "\nChoice 0:exit";

 

  cout << "\n\nEnter your choice: ";

 

  cin >> choice;

 

  cout << "\n";

 

  switch(choice)

  {

      case 1: add();

              break;

             

      case 2: sub();

              break;

             

      case 3: mul();

              break;

     

      case 0: cout << "Exited";

              exit(1);

     

      default: cout << "Invalid";      

  }

  main();  

}

//Addition Of Matrix

void add()

{

  int rows1,cols1,i,j,rows2,cols2;

 

  cout << "\nmatrix1 # of rows: ";

  cin >> rows1;

 

  cout << "\nmatrix1 # of columns: ";

  cin >> cols1;

 

   int m1[rows1][cols1];

 

  //Taking First Matrix

  for(i=0;i<rows1;i++)

      for(j=0;j<cols1;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m1[i][j];

          cout << "\n";

      }

  //Printing 1st Matrix

  for(i=0;i<rows1;i++)

  {

      for(j=0;j<cols1;j++)

          cout << m1[i][j] << " ";

      cout << "\n";

  }

     

  cout << "\nmatrix2 # of rows: ";

  cin >> rows2;

 

  cout << "\nmatrix2 # of columns: ";

  cin >> cols2;

 

  int m2[rows2][cols2];

  //Taking Second Matrix

  for(i=0;i<rows2;i++)

      for(j=0;j<cols2;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m2[i][j];

          cout << "\n";

      }

  //Displaying second Matrix

  cout << "\n";

  for(i=0;i<rows2;i++)

  {

      for(j=0;j<cols2;j++)

          cout << m2[i][j] << " ";

      cout << "\n";

  }

  //Displaying Sum of m1 & m2

  if(rows1 == rows2 && cols1 == cols2)

  {

      cout << "\n";

      for(i=0;i<rows1;i++)

      {

          for(j=0;j<cols1;j++)

              cout << m1[i][j]+m2[i][j] << " ";

          cout << "\n";  

      }

  }

  else

      cout << "operation is not supported";

     

  main();

 

}

void sub()

{

  int rows1,cols1,i,j,k,rows2,cols2;

  cout << "\nmatrix1 # of rows: ";

  cin >> rows1;

 

  cout << "\nmatrix1 # of columns: ";

  cin >> cols1;

 

   int m1[rows1][cols1];

 

  for(i=0;i<rows1;i++)

      for(j=0;j<cols1;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m1[i][j];

          cout << "\n";

      }

 

  for(i=0;i<rows1;i++)

  {

      for(j=0;j<cols1;j++)

          cout << m1[i][j] << " ";

      cout << "\n";

  }

     

  cout << "\nmatrix2 # of rows: ";

  cin >> rows2;

 

  cout << "\nmatrix2 # of columns: ";

  cin >> cols2;

 

  int m2[rows2][cols2];

 

  for(i=0;i<rows2;i++)

      for(j=0;j<cols2;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m2[i][j];

          cout << "\n";

      }

 

  for(i=0;i<rows2;i++)

  {

      for(j=0;j<cols2;j++)

          cout << m1[i][j] << " ";

      cout << "\n";

  }

  cout << "\n";

  //Displaying Subtraction of m1 & m2

  if(rows1 == rows2 && cols1 == cols2)

  {

      for(i=0;i<rows1;i++)

      {

          for(j=0;j<cols1;j++)

              cout << m1[i][j]-m2[i][j] << " ";

          cout << "\n";  

      }

  }

  else

      cout << "operation is not supported";

     

  main();

 

}

void mul()

{

  int rows1,cols1,i,j,k,rows2,cols2,mul[10][10];

  cout << "\nmatrix1 # of rows: ";

  cin >> rows1;

 

  cout << "\nmatrix1 # of columns: ";

  cin >> cols1;

 

   int m1[rows1][cols1];

 

  for(i=0;i<rows1;i++)

      for(j=0;j<cols1;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m1[i][j];

          cout << "\n";

      }

  cout << "\n";

  for(i=0;i<rows1;i++)

  {

      for(j=0;j<cols1;j++)

          cout << m1[i][j] << " ";

      cout << "\n";

  }

     

  cout << "\nmatrix2 # of rows: ";

  cin >> rows2;

 

  cout << "\nmatrix2 # of columns: ";

  cin >> cols2;

 

  int m2[rows2][cols2];

 

  for(i=0;i<rows2;i++)

      for(j=0;j<cols2;j++)

      {

          cout << "\nEnter element (" << i << "," << j << "): ";

          cin >> m2[i][j];

          cout << "\n";

      }

  cout << "\n";

  //Displaying Matrix 2

  for(i=0;i<rows2;i++)

  {

      for(j=0;j<cols2;j++)

          cout << m2[i][j] << " ";

      cout << "\n";

  }

     

  if(cols1!=rows2)

      cout << "operation is not supported";

  else

  {

      //Initializing results as 0

      for(i = 0; i < rows1; ++i)

  for(j = 0; j < cols2; ++j)

  mul[i][j]=0;

// Multiplying matrix m1 and m2 and storing in array mul.

  for(i = 0; i < rows1; i++)

  for(j = 0; j < cols2; j++)

  for(k = 0; k < cols1; k++)

  mul[i][j] += m1[i][k] * m2[k][j];

// Displaying the result.

  cout << "\n";

  for(i = 0; i < rows1; ++i)

      for(j = 0; j < cols2; ++j)

      {

      cout << " " << mul[i][j];

      if(j == cols2-1)

      cout << endl;

      }

      }  

  main();

 }

You might be interested in
A medium-sized jet has a 3.8-mm-diameter fuselage and a loaded mass of 85,000 kg. The drag on an airplane is primarily due to th
SCORPION-xisa [38]

Answer:

F_{thrust} ≅ 111 KN

Explanation:

Given that;

A medium-sized jet has a 3.8-mm-diameter i.e diameter (d) = 3.8

mass = 85,000 kg

drag co-efficient (C) = 0.37

(velocity (v)= 230 m/s

density (ρ) = 1.0 kg/m³

To calculate the thrust; we need to determine the relation of the drag force; which is given as:

F_{drag} = \frac{1}{2} × CρAv²

where;

ρ = density of air wind.

C = drag co-efficient

A = Area of the jet

v = velocity of the jet

From the question, we can deduce that the jet is in motion with a constant speed; as such: the net force acting on the jet in the air = 0

SO, F_{drag}-F_{thrust} = 0

We can as well say:

F_{drag}= F_{thrust}

We can now replace F_{thrust} with F_{drag} in the above equation.

Therefore, F_{thrust} = \frac{1}{2} × CρAv²

The A which stands as the area of the jet is given by the formula:

A=\frac{\pi d^2}{4}

We can now have a new equation after substituting our A into the previous equation as:

F_{thrust} = \frac{1}{2} × Cρ (\frac{\pi d^2}{4})v^2

Substituting our data from above; we have:

F_{thrust} = \frac{1}{2} × (0.37)(1.0kg/m^3)(\frac{\pi(3.8m)^2 }{4})(230m/s)^2

F_{thrust} = \frac{1}{8}   (0.37)(1.0kg/m^3)({\pi(3.8m)^2 })(230m/s)^2

F_{thrust} = 110,990N

F_{thrust}  in N (newton) to KN (kilo-newton) will be:

F_{thrust} = (110,990N)*\frac{1KN}{1,000N}

F_{thrust} = 110.990 KN

F_{thrust} ≅ 111 KN

In conclusion, the jet engine needed to provide 111 KN thrust in order to cruise at 230 m/s at an altitude where the air density is 1.0 kg/m³.

5 0
3 years ago
What type of car engine is best for cold weather.
Komok [63]

Answer:Antifreeze/coolant

Explanation: keeps your engine cool in warm weather and keeps it from freezing up in the winter. A 50-50 mix of full strength coolant and water generally protects to around -30 degrees Fahrenheit. Make sure you check with the supplier or your owner's manual for the correct formulation

5 0
2 years ago
Which option best describes a way engineers can provide maintenance, diagnoses, upgrades, or duplicates even for products they d
guajiro [1.7K]

Answer:

Reverse Engineering

Explanation:

Just took the test

4 0
2 years ago
Velocity components in an incompressible flow are: v = 3xy + x^2 y: w = 0. Determine the velocity component in the x-direction.
cupoosta [38]

Answer:

Velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

Explanation:

   v=3xy+x^{2}y

We know that for incompressible flow

   \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}=0

\frac{\partial v}{\partial y}=3x+x^{2}

So   \frac{\partial u}{\partial x}+3x+x^{2}=0

\frac{\partial u}{\partial x}= -3x-x^{2}

By integrate with respect to x,we will find

u=-\frac{3}{2}x^2-\frac{1}{3}x^3+C

So the velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

3 0
3 years ago
Random ____ fluctuations in the early universe were stretched by a period of intense inflation, resulting in permanent density f
fgiga [73]

Answer:

Quantum

Explanation:

Appearance of energy particles from any where as allowed by uncertainty principle.

7 0
2 years ago
Other questions:
  • Before you calculate the moment capacity for a steel beam, you have to determine the classification of beam.
    10·1 answer
  • What is compression ratio of an Otto cycle? How does it affect the thermal efficiency of the cycle?
    14·1 answer
  • Explain why the failure of a garden hose occurred near its end and why the tear occurred along its length. Use numerical values
    15·1 answer
  • For a 20 ohm resistor R, the current i = 2 A. What is the voltage V? Submit your answer as a number without units. ​
    12·1 answer
  • the voltage across a 5mH inductor is 5[1-exp(-0.5t)]V. Calculate the current through the inductor and the energy stored in the i
    6·1 answer
  • A tool used to put a concave edge on a plane iron is
    6·1 answer
  • To ensure that a vehicle crash is inelastic, vehicle safety designers add crumple zones to vehicles. A crumple zone is a part of
    12·1 answer
  • Technician A says that fuel filler caps with pressure and vacuum vents are used with EVAP system fuel tanks. Technician B says t
    5·1 answer
  • Find the mean deviation of the set of numbers<br> (a) 12, 6, 7, 3, 15, 10, 18,5
    7·2 answers
  • ​please how to drawing mechanical drawing after connecting the all parts thanks
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!