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
Whatever they said bbbbbbbbbbbbbbbbbb
solong [7]

Answer:

yh and I said aaaaaaaaaaaa

Explanation:

7 0
3 years ago
Read 2 more answers
Examples of reciprocating motion in daily life
bonufazy [111]

Answer:

Examples of reciprocating motion in daily life are;

1) The needles of a sewing machine

2) Electric powered reciprocating saw blade

3) The motion of a manual tire pump

Explanation:

A reciprocating motion is a motion that consists of motion of a part in an upward and downwards (\updownarrow) or in a backward and forward (↔) direction repetitively

Examples of reciprocating motion in daily life includes the reciprocating motion of the needles of a sewing machine and the reciprocating motion of the reciprocating saw and the motion of a manual tire pump

In a sewing machine, a crank shaft in between a wheel and the needle transforms the rotary motion of the wheel into reciprocating motion of the needle.

8 0
2 years ago
1. (5 pts) An adiabatic steam turbine operating reversibly in a powerplant receives 5 kg/s steam at 3000 kPa, 500 °C. Twenty per
KiRa [710]

Answer:

temperature of first extraction 330.8°C

temperature of second extraction 140.8°C

power output=3168Kw

Explanation:

Hello!

To solve this problem we must use the following steps.

1. We will call 1 the water vapor inlet, 2 the first extraction at 100kPa and 3 the second extraction at 200kPa

2. We use the continuity equation that states that the mass flow that enters must equal the two mass flows that leave

m1=m2+m3

As the problem says, 20% of the flow represents the first extraction for which 5 * 20% = 1kg / s

solving

5=1+m3

m3=4kg/s

3.

we find the enthalpies and temeperatures in each of the states, using thermodynamic tables

Through laboratory tests, thermodynamic tables were developed, these allow to know all the thermodynamic properties of a substance (entropy, enthalpy, pressure, specific volume, internal energy etc ..)  

through prior knowledge of two other properties

4.we find the enthalpy and entropy of state 1 using pressure and temperature

h1=Enthalpy(Water;T=T1;P=P1)

h1=3457KJ/kg

s1=Entropy(Water;T=T1;P=P1)

s1=7.234KJ/kg

4.

remembering that it is a reversible process we find the enthalpy and the temperature in the first extraction with the pressure 1000 kPa and the entropy of state 1

h2=Enthalpy(Water;s=s1;P=P2)

h2=3116KJ/kg

T2=Temperature(Water;P=P2;s=s1)

T2=330.8°C

5.we find the enthalpy and the temperature in the second extraction with the pressure 200 kPav y the entropy of state 1

h3=Enthalpy(Water;s=s1;P=P3)

h3=2750KJ/kg

T3=Temperature(Water;P=P3;s=s1)

T3=140.8°C

6.

Finally, to find the power of the turbine, we must use the first law of thermodynamics that states that the energy that enters is the same that must come out.

For this case, the turbine uses a mass flow of 5kg / s until the first extraction, and then uses a mass flow of 4kg / s for the second extraction, taking into account the above we infer the following equation

W=m1(h1-h2)+m3(h2-h3)

W=5(3457-3116)+4(3116-2750)=3168Kw

7 0
3 years ago
An inductor has a 50.0-Ω reactance when connected to a 60.0-Hz source. The inductor is removed and then connected to a 45.0-Hz s
nignag [31]

Given:

X_{L} = 50.0 \ohm

frequency, f = 60.0 Hz

frequency, f' = 45.0 Hz

V_rms} = 85.0 V

Solution:

To calculate max current in inductor, I_{L(max):

At f = 60.0 Hz

X_{L} = 2\pi fL

50.0 = 2\pi\times 60.0\times L

L = 0.1326 H

Now, reactance X_{L} at f' = 45.0 Hz:

X'_{L} = 2\pi f'L

X'_{L} = 2\pi\times 45.0\times 0.13263 = 37.5\ohm

Now, I_{L(max) is given by:

I_{L(max) = \sqrt {\frac{2V_{rms}}{X'_{L}}}

I_{L(max) = \sqrt {\frac{2\times 85.0}{37.5}} = 2.13 A

Therefore,  max current in the inductor, I_{L(max) = 2.13 A

7 0
3 years ago
What is the criteria for a guard having to be used on a machine?
evablogger [386]

Answer:

Machine Safeguards must meet these minimum general requirements: Prevent contact: The safeguard must prevent hands, arms, or any other part of a worker's body from making contact with dangerous moving parts. Be secure: Workers should not be able to easily remove or tamper with the safeguard.

8 0
3 years ago
Other questions:
  • Consider flow in between two parallel plates located a distance H from each other. Fluid flow is driven by the bottom plate movi
    15·1 answer
  • Find the mass if the force is 18 N and the acceleration is 2 m/s2
    8·2 answers
  • The phrase "positive to positive, negative to ground" is correct when jump starting a car.
    9·1 answer
  • 1) Pareto charts are used to: A) identify inspection points in a process. B) outline production schedules. C) organize errors, p
    6·1 answer
  • In unguided medium (free space), the electromagnetic (EM) signal wave spreads as it leaves the transmit antenna. Since the power
    10·1 answer
  • The component of a fluid system where a fluid is stored, but not under pressure, is called a container.
    5·1 answer
  • A 50 mol% mixture of propane (1) and n-butane (2) enters an isothermal flash drum at 37°C. If the flash drum is maintained at 0.
    12·1 answer
  • Given the latent heat of fusion (melting) and the latent heat of vaporisation for water are Δhs = 333.2 kJ/kg and Δhv = 2257 kJ/
    15·1 answer
  • The coolant heat storage system:
    10·1 answer
  • Who is???????????????????
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!