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]
3 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]3 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
Primary Creep: slope (creep rate) decreases with time
Igoryamba

Answer:

true

Explanation:

Creep is known as the time dependent deformation of structure due to constant load acting on the body.

Creep is generally seen at high temperature.

Due to creep the length of the structure increases which is not fit for serviceability purpose.

When time passes structure gain strength as the structure strength increases with time so creep tends to decrease.

When we talk about Creep rate for new structure the creep will be more than the old structure i.e. the creep rate decreases with time.

5 0
3 years ago
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
Draw your vectors starting at the black dot. The orientation of your vectors will be graded. The exact length of your vectors wi
soldier1979 [14.2K]

A vector is a phenomenon which in mostly used in mathematics and physics and is related to direction and size.

<u>Explanation:</u>

In mathematics and physics, a vector is a component of a vector space. For some, particular vector spaces, the vectors have gotten explicit names, which are recorded beneath. Verifiably, vectors were presented in geometry and material science before the formalization of the idea of vector space.  

A vector is an amount or phenomenon that has two autonomous properties: magnitude and direction. The term likewise means the numerical or geometrical portrayal of such an amount.

4 0
3 years ago
2) The switch in the circuit below has been closed a long time. At t=0, it is opened.
saul85 [17]

Answer:

  il(t) = e^(-100t)

Explanation:

The current from the source when the switch is closed is the current through an equivalent load of 15 + 50║50 = 15+25 = 40 ohms. That is, it is 80/40 = 2 amperes. That current is split evenly between the two parallel 50-ohm resistors, so the initial inductor current is 2/2 = 1 ampere.

The time constant is L/R = 0.20/20 = 0.01 seconds. Then the decaying current is described by ...

  il(t) = e^(-t/.01)

  il(t) = e^(-100t) . . . amperes

8 0
2 years ago
Refrigerant-134a at 400 psia has a specific volume of 0.1144 ft3/lbm. Determine the temperature of the refrigerant based on (a)
vekshin1

Answer:

a) Using Ideal gas Equation, T = 434.98°R = 435°R

b) Using Van Der Waal's Equation, T = 637.32°R = 637°R

c) T obtained from the refrigerant tables at P = 400 psia and v = 0.1144 ft³/lbm is T = 559.67°R = 560°R

Explanation:

a) Ideal gas Equation

PV = mRT

T = PV/mR

P = pressure = 400 psia

V/m = specific volume = 0.1144 ft³/lbm

R = gas constant = 0.1052 psia.ft³/lbm.°R

T = 400 × 0.1144/0.1052 = 434.98 °R

b) Van Der Waal's Equation

T = (1/R) (P + (a/v²)) (v - b)

a = Van Der Waal's constant = (27R²(T꜀ᵣ)²)/(64P꜀ᵣ)

R = 0.1052 psia.ft³/lbm.°R

T꜀ᵣ = critical temperature for refrigerant-134a (from the refrigerant tables) = 673.6°R

P꜀ᵣ = critical pressure for refrigerant-134a (from the refrigerant tables) = 588.7 psia

a = (27 × 0.1052² × 673.6²)/(64 × 588.7)

a = 3.596 ft⁶.psia/lbm²

b = (RT꜀ᵣ)/8P꜀ᵣ

b = (0.1052 × 673.6)/(8 × 588.7) = 0.01504 ft³/lbm

T = (1/0.1052) (400 + (3.596/0.1144²) (0.1144 - 0.01504) = 637.32°R

c) The temperature for the refrigerant-134a as obtained from the refrigerant tables at P = 400 psia and v = 0.1144 ft³/lbm is

T = 100°F = 559.67°R

7 0
3 years ago
Other questions:
  • How an AK 47 gun was works​
    14·1 answer
  • For some transformation having kinetics that obey the Avrami equation , the parameter n is known to have a value of 1.1. If, aft
    6·1 answer
  • Suppose an assembly requires five components from five different vendors. To guarantee starting the assembly on time with 90 per
    14·1 answer
  • ________ is the most theoretical computing discipline, focusing mostly on finding new and better ways for computers to work
    9·1 answer
  • An engineering firm just lost one of their larger customers. The firm president says that the solution to this problem is to fir
    6·1 answer
  • Oliver is designing a new children’s slide to increase the speed at which a child can descend. His first design involved steel b
    15·1 answer
  • Which of the following is an example of a social need?
    5·1 answer
  • Jnjn freeeeeeeeeeeeeeeeeeeeeeeeeeeeeee pointtttttttttt
    15·2 answers
  • For some transformation having kinetics that obey the Avrami equation, the parameter n is known to have a value of 2. If, after
    14·1 answer
  • Technician A says that synthetic blend oil has the same service life as that of full synthetic oils. Technician B says that conv
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!