answer.
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
agasfer [191]
2 years ago
8

Code scramble: make the program sort the three numbers x, y and z into increasing order, so that x has the smallest value, y has

the next smallest value, and z has the largest value. Drag and drop with your mouse to rearrange the lines.
Engineering
1 answer:
riadik2000 [5.3K]2 years ago
3 0

Answer:

This question is taken from code scramble exercise which has scattered lines which are to be arranged by dragging and dropping with mouse to  to get the desired output in which x has the smallest value, y has the next smallest value, and z has the largest value. So the correct arrangement is as following:

tmp=max(x,y)  

x=min(x,y)  

y=tmp  

tmp=max(y,z)  

y=min(y,z)

z=tmp  

tmp=max(x,y)  

x=min(x,y)  

y=tmp

Explanation:

So the flow works as following:

First the maximum of x and y is taken and the result is stored in a temporary variable tmp which is used so that the original values do not get affected or modified by the operations performed by the functions. Lets say that x=30 y=15 and z=40

Now the max() functions returns the maximum from the values of x and y. As x=30 and y=15 so value of x is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and now x=15

y = tmp means now the value in tmp is copied to y, So y = 30

Next the max() function finds the maximum value from the values of y and z. As y=30 and z=40 So the maximum value is 40 so tmp variable now contains the value 40.

Next the min() function finds the minimum from the values of y and z and stores the result in y. As the minimum value is 30 so this value is stored in y which means y remains 30 so, y=30

z = tmp means now the value in tmp is copied to z, So z= 40

Now the max() functions returns the maximum from the values of x and y. After the operations of above functions the new value of x and y are: x=15 and y=30 so value of y is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and x remains: x=15

y = tmp means now the value in tmp is copied to y, So y remains: y = 30

So the final values of x, y and z are:

x = 15 y = 30 z = 40

If you want to make a program which sort the values in x, y and z then i am providing a simple Python program that serves the purpose:

x = int(input("enter first number: "))

y = int(input("enter second number: "))

z = int(input("enter third number: "))

a1 = min(x, y, z)

a3 = max(x, y, z)

a2 = (x + y + z) - a1 - a3

print("x =",a1,"y=",a2,"z=",a3)

The program asks user to enter the value for x, y and z.

Then the minimum value from the values of x,y and z is computed using min() function and the result is stored in a1. This will be the value of x. Then the maximum value from value of x,y and z is computed using max() function and the result is stored in a2. This will be the value of z. Next the statement: a2 = (x + y + z) - a1 - a3  works as following:

Lets say the values of x = 30 y = 15 and z = 40 So a1 = 15 and a2 = 40

a2 = 30 + 15 + 40 - 15 - 40

a2 = 30

This is the value of y

So  print("x = ",a1,"y = ",a2,"z = ",a3) displays the following output:

x = 15 y = 30 z = 40

You might be interested in
49. A solenoid coil with a resistance of 30 ohms and an inductance of 200 milli-henrys, is connected to a 230VAC, 50Hz supply. D
Leya [2.2K]

Answer:

69.59 ohms

Explanation:

Given that

L=200\ mH

F=50\ hZ

R=30\ ohms

For inductance

X_L=2\times \pi\times f \times LX_L\\=2\times \pi \times 50\times 200\times 10^{-3}\\=62.8\ ohm

R=30\ ohmsImpedance\\Z=\sqrt{R^2+X_L^2}\\Z=\sqrt{30^2+62.8^2}\ ohms\\Z =69.59\ ohms

8 0
2 years ago
what is the advantage of decreasing the field current of a separately excited dc motor below its nominal value
enyata [817]

Answer:

Ability to rotate at higher speeds

Explanation:

Constant K1 becomes greater than the other constant K2

This translates to that the motor being able to rotate at high speeds, without necessarily exceeding the nominal armature voltage.

The armature voltage is the voltage that is developed around the terminals of the armature winding of an Alternating Current, i.e AC or a Direct Current, i.e DC machine during the period in which it tries to generate power.

6 0
2 years ago
5. Which of these materials in a shop contain metals and toxins and can pollute the environment? A) Antifreeze B) Solvents C) Ba
Elza [17]
As a multiple choice the only correct answer is D
3 0
2 years ago
Read 2 more answers
Identify the four engineering economy symbols and their values from the following problem statement. Use a question mark with th
Vilka [71]

Answer:

The company will have $311,424 in its investment set-aside account.

Explanation:

To determine the amount of money that the company will have after 7 years with an interest rate of 11% per year, we must calculate the price to start with an increase of 11%, and then repeat the operation until reaching seven years:

Year 0: 150,000

Year 1: 150,000 x 1.11 = 166,500

Year 2: 166,000 x 1.11 = 184,815

Year 3: 184,815 x 1.11 = 205,144.65

Year 4: 205,144.65 x 1.11 = 227,710.56

Year 5: 227,710.56 x 1.11 = 252,758.72

Year 6: 252,758.72 x 1.11 = 280,562.18

Year 7: 280,562.18 x 1.11 = 311,424

3 0
2 years ago
Consider an infinitely thin flat plate of chord c at an angle of attack α in a supersonic flow. The pressure on the upper and lo
amm1812

Answer:

X_cp = c/2

Explanation:

We are given;

Chord = c

Angle of attack = α

p u (s) = c 1

​p1(s)=c2,

and c2 > c1

First of all, we need to find the resultant normal force on the plate and the total moment about leading edge.

I've attached the solution

4 0
2 years ago
Other questions:
  • PDAs with two stacks are strictly more powerful than PDAs with one stack. Prove that 2-stack PDAs are not a valid model for CFLs
    12·1 answer
  • Write multiple if statements: If carYear is before 1967, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • If a server takes precisely 15 seconds to serve a customer and customers arrive exactly every 20 seconds, what is the average wa
    7·1 answer
  • Water is the working fluid in an ideal Rankine cycle. The condenser pressure is 8 kPa, and saturated vapor enters the turbine at
    10·1 answer
  • If the electric field just outside a thin conducting sheet is equal to 1.5 N/C, determine the surface charge density on the cond
    9·1 answer
  • Carbon dioxide gas enters a pipe at 3 MPa and 500 K at a rate of 2 kg/s. CO2 is cooled at constant pressure as it flows in the p
    10·1 answer
  • A horizontal pipe has an abrupt expansion from D1 5 8 cm to D2 5 16 cm. The water velocity in the smaller section is 10 m/s and
    7·1 answer
  • Water enters a circular tube whose walls are maintained at constant temperature at specified flow rate and temperature. For full
    8·1 answer
  • a. (24 points) Describe the microstructure present in a 10110 steel after each step in each of the following heat treatments (no
    10·1 answer
  • How does Accenture generate value for clients through Agile and DevOps?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!