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
Semenov [28]
3 years ago
9

Using a conditional expression, write a statement that increments num_users if update_direction is 3, otherwise decrements num_u

sers. Sample output with inputs: 8 3 New value is: 9
Engineering
1 answer:
yuradex [85]3 years ago
6 0

Answer:

num_users = (update_direction == 3) ? (++num_users) : (--num_users);

Explanation:

A. Using the regular if..else statement, the response to the question would be like so;

if (update_direction == 3) {

  ++num_users;  // this will increment num_users by 1

}

else {

 -- num_users;    //this will decrement num_users by 1

}

Note: A conditional expression has the following format;

<em>testcondition ? true : false;</em>

where

a. <em>testcondition </em>is the condition to be tested for. In this case, if update_direction is 3 (update_direction == 3).

b. <em>true </em>is the statement to be executed if the <em>testcondition</em> is true.

c. false is the statement to be executed it the <em>testcondition</em> is false.

B. Converting the above code snippet (the if..else statement in A above) into a conditional expression statement we have;

num_users = (update_direction == 3) ? (++num_users) : (--num_users);

<em>Hope this helps!</em>

You might be interested in
A geothermal heat pump absorbs 15 KJ/s of heat from the Earth 15 m below a house. This heat pump uses a 7.45 kJ/s compressor.
Oxana [17]

Answer:

COP of heat pump=3.013

COP of cycle=1.124

Explanation

W = Q2 - Q1 ----- equation 1

W = work done

Q2 = final energy

Q1 = initial energy

A) calculate the COP of the heat pump

COP =Q2/W

from equation 1

Q2 = Q1 + W = 15 + 7.45 = 22.45 KW

therefore COP =22.45/7.45  = 3.013

B) COP when cycle is reversed

COP = Q1/W

from equation 1

Q1 + W = Q2 ------ equation 2

Q2 = 15 Btu/s = 15 * 1.055 = 15.825 KW therefore from equation 2

Q1 = 8.375 KW

COP =8.375/7.45   = 1.124

6 0
3 years ago
Read 2 more answers
The costs of mining and transporting coal are roughly independent of the heating value of the coal. Consider:
Paul [167]

Answer:

2

Explanation:

5 0
3 years ago
lmfsojdkkfjdsskfsaj;fkljsldfkjlsdkfdjs;dklfjsldkfjflkjfkjfldjsdlfgkljshglksdjfghdskjgsdfkfjghlsdfghsdkjfghlskjdfhglskjdfghkjsfhg
vodka [1.7K]

Answer:

(⌐■-■) (⌐■-■) (⌐■-■) (⌐■-■)

5 0
2 years ago
A commercial refrigerator with refrigerant -134a as the working fluid is used to keep the refrigerated space at -30C by rejectin
Mariana [72]

Answer:

a) 0.487

b) refrigeration load = 5.46w

c) cop = 2.24

d)ref load max = 12.43kw

Explanation:

6 0
3 years ago
Read 3 more answers
The ???? − i relationship for an electromagnetic system is given by ???? = 1.2i1/2 g where g is the air-gap length. For current
Artemon [7]

Answer:

a) The mechanical force is -226.2 N

b) Using the coenergy the mechanical force is -226.2 N

Explanation:

a) Energy of the system:

\lambda =\frac{1.2*i^{1/2} }{g} \\i=(\frac{\lambda g}{1.2} )^{2}

\frac{\delta w_{f} }{\delta g} =\frac{g^{2}\lambda ^{3}  }{3*1.2^{2} }

f_{m}=- \frac{\delta w_{f} }{\delta g} =-\frac{g^{2}\lambda ^{3}  }{3*1.2^{2} }

If i = 2A and g = 10 cm

\lambda =\frac{1.2*i^{1/2} }{g} =\frac{1.2*2^{1/2} }{10x10^{-2} } =16.97

f_{m}=-\frac{g^{2}\lambda ^{3}  }{3*1.2^{2} }=-\frac{16.97^{3}*2*0.1 }{3*1.2^{2} } =-226.2N

b) Using the coenergy of the system:

f_{m}=- \frac{\delta w_{f} }{\delta g} =-\frac{1.2*2*i^{3/2}  }{3*g^{2} }=-\frac{1.2*2*2^{3/2} }{3*0.1^{2} } =-226.2N

8 0
3 years ago
Other questions:
  • The rigid beam is supported by a pin at C and an A992 steel guy wire AB of length 6 ft. If the wire has a diameter of 0.2 in., d
    14·1 answer
  • Consider two different types of motors. Motor A has a characteristic life of 4100 hours (based on a MTTF of 4650 hours) and a sh
    10·1 answer
  • A well-established way of power generation involves the utilization of geothermal energy-the energy of hot water that exists nat
    9·1 answer
  • A rectangular open channel is 20 ft wide and has a bed slope of 0.007. Manning's roughness coefficient n is 0.03. It is in unifo
    10·1 answer
  • The information on a can of pop indicates that the can contains 360 mL. The mass of a full can of pop is 0.369 kg, while an empt
    14·1 answer
  • The insulator is the connection between the grounded circuit conductor and the equipment grounding conductor at the service.
    15·1 answer
  • What is the friction factor for fully developed flow in a circular pipe where Reynolds number is 1000
    6·1 answer
  • Name the famous engineer in the world​
    10·2 answers
  • Question Completion Status:
    6·1 answer
  • There are some sections of the SDS that are not mandatory.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!