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
Aleks04 [339]
3 years ago
6

Bob and Alice are solving practice problems for CSE 2320. They look at this code: for(i = 1; i <= N; i = (i*2)+17 ) for(k = i

+1; k <= i+N; k = k+1) // notice i in i+1 and i+N printf("B"); Alice says the loops are dependent. Bob says they are not dependent. Who is correct? ____________ What do you think? Are they dependent or not dependent? They are __________
Engineering
2 answers:
MissTica3 years ago
8 0

Answer:

Alice is correct.

The loop are dependent.

Explanation:

for(i = 1; i <= N; i = (i*2)+17 )

for(k = i+1; k <= i+N; k = k+1) // notice i in i+1 and i+N

printf("B")

This is a nested for-loop.

After the first for-loop opening, there is no block of statement to be executed rather a for-loop is called again. And the second for-loop uses the value of i from the first for-loop. The value of N is both called from outside the loop.

So, the second for-loop depend on the first for loop to get the value of i. For clarity purpose, code indentation or use of curly brace is advised.

ZanzabumX [31]3 years ago
4 0
<h2>Answer:</h2>

Alice is correct

They are dependent

<h2>Explanation:</h2><h2></h2>

<em>The code snippet can be re-written as follows;</em>

<em></em>

for(i = 1; i <= N; i = (i*2)+17 )

  for(k = i+1; k <= i+N; k = k+1)

<em>Which can also be re-written as;</em>

<em></em>

for(i = 1; i <= N; i = (i*2)+17 ) {

   for(k = i+1; k <= i+N; k = k+1){

   }

}

In many programming languages, curly brackets are used for grouping blocks of codes. For a for loop, while loop, if statement and other related control structures, the lines of statement(s) inside their curly brackets are executed when they are encountered. In the case where any of these control statements is written without curly brackets, the next line of code (and that only) following it belongs to its block.  

Consequential from the foregoing, at each of cycles of the <em>outer</em> <em>for loop</em> in the first code snippet above, the <em>inner for loop </em>will be executed. In other words, the inner for loop belongs to the block of the outer for loop though there is no curly bracket included. This also means that once a control statement has only a single line of code to be executed or to be a part of its block, curly brackets are not required. Therefore, the two versions of code snippets written above are identical and equivalent.

With the aforementioned, it is easy to say and see that the Alice is correct that the loops are dependent on each other.

You might be interested in
You can assume there is no pressure drop between the exit of the compressor and the entrance of the turbine. All the power from
Eddi Din [679]

Answer:

s6rt5x11j4fgu

j4

cf53yhu5

y4

hh

Explanation:

j

6 0
3 years ago
Does a thicker core make an electromagnet stronger?
mel-nik [20]

Answer:

Yes

Explanation:

The core of an electromagnet serves to stabilize the magnetic field created by the wire. The thicker the core, the more metal there is to amplify the current. Therefore, a thicker core does make an electromagnet stronger. Hope this helps!

6 0
3 years ago
Read 2 more answers
The 50mm diameter cylinder is made from Am 1004-T61 magnesium (E = 44.7GPa, a = 26x10^-6/°C)
BartSMP [9]

Answer:

......................

Explanation:

3 0
2 years ago
Steam at 20 bars is in the saturated vapor state (call this state 1) and contained in a pistoncylinderdevice with a volume of 0.
saul85 [17]

Answer:

Explanation:

Given that:

<u>At state 1:</u>

Pressure P₁ = 20 bar

Volume V₁ = 0.03 \mathbf{m^{3}}

From the tables at saturated vapour;

Temperature T₁ = 212.4⁰ C  ; v_1 = vg_1 = 0.0996 \mathbf{m^{3}} / kg

The mass inside the cylinder is m = 0.3 kg, which is constant.

The specific internal energy u₁ = ug₁ = 2599.2 kJ/kg

<u>At state 2:</u>

Temperature T₂ = 200⁰ C

Since the 1 - 2 occurs in an isochoric process v₂ = v₁ = 0.099 \mathbf{m^{3}} / kg

From temperature T₂ = 200⁰ C

v_f_2 = 0.0016 \ m^3/kg  

vg_2 = 0.127 \ m^3/kg  

Since  vf_2 < v_2 , the saturated pressure at state 2 i.e. P₂ = 15.5 bar

Mixture quality x_2 = \dfrac{v_2-vf_2}{vg_2 -vf_2}

x_2 = \dfrac{(0.099-0.0016)m^3/kg}{(0.127 -0.0016) m^3/kg}

x_2 = \dfrac{(0.0974)m^3/kg}{(0.1254) m^3/kg}

\mathsf{x_2 =0.78}

At temperature T₂, the specific internal energy u_f_2 = 850.6 \ kJ/kg , also ug_2 = 2594.3 \ kJ/kg

Thus,

u_2 = uf_2 + x_2 (ug_2 -uf_2)

u_2 =850.6  +0.78 (2594.3 -850.6)

u_2 =850.6  +1360.086

u_2 =2210.686 \ kJ/kg

<u>At state 3:</u>

Temperature T_3=T_2 = 200 ^0 C ,

V_3 = 2V_1 = 0.06 \ m^3

Specific volume v_3 = 0.2  \ m^3/kg

Thus; vg_3 =vg_2 = 0.127 \ m^3/kg ,

SInce v_3 > vg_3, therefore, the phase is in a superheated vapour state.

From the tables of superheated vapour tables; at v_3 = 0.2  \ m^3/kg and T₃ = 200⁰ C

The pressure = 10 bar and v =0.206 \ m^3/kg

The specific internal energy u_3 at the pressure of 10 bar = 2622.3 kJ/kg

The changes in the specific internal energy is:

u_2-u_1

= (2210.686 - 2599.2) kJ/kg

= -388.514 kJ/kg

≅ - 389 kJ/kg

u_3-u_2

= (2622.3 - 2210.686)  kJ/kg

= 411.614 kJ/kg

≅ 410 kJ/kg  

We can see the correct sketches of the T-v plot showing the diagrammatic expression in the image attached below.

3 0
3 years ago
A good rule of thumb in hazardous conditions is to _____.
Aloiza [94]

Answer:

C. Have your hazard lights on

Explanation:

Speeding up will cause an accident

Counter steering is not easy to do

Slowing down my result in you being rear ended

5 0
2 years ago
Read 2 more answers
Other questions:
  • A fluid has a dynamic viscosity of 0.048 Pa.s and a specific gravity of 0.913. For the flow of such a fluid over a flat solid su
    10·1 answer
  • tech a says that a tire with more wear on the center of the tread is caused by under inflation of the size tech b says featherin
    12·1 answer
  • One kilogram of water fills a 150-L rigid container at an initial pressure of 2 MPa. The container is then cooled to 40∘C. Deter
    7·1 answer
  • Use the map to complete the table by selecting the boxes that best describe how ocean currents affect the
    14·1 answer
  • Design an Armstrong indirect FM modulator to generate an FM signal with a carrier frequency 98.1 MHz and a frequency deviation △
    15·1 answer
  • A crystalline grain of aluminum in a metal plate is situated so that a tensile load is oriented along the [1 1 1] direction. Wha
    9·1 answer
  • What is a beam on a bridge? what does it do?
    6·1 answer
  • Which of the following elements found in fertilizer helps plants produce fruit?
    15·2 answers
  • A bridge a mass of 800 kg and is able to support up to 4 560 kg. What is its structural efficiency?
    8·2 answers
  • Which of the following situations best describes student engaged in active learning
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!