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
Join the pad let <br><br> https://pad let.com/56021812/8g75510tedza5v2a
labwork [276]
What the brxh is a parley
7 0
3 years ago
Read 2 more answers
Opposition to current flow, restricts or resists current flow
BlackZzzverrR [31]

Answer:

The answer is c-resistance

8 0
3 years ago
A 993-kg car starts from rest at the bottom of a drive way and has a speed of 3.00 m/s at a point where the drive way has risen
tino4ka555 [31]

Answer:

13177.34 J

Explanation:

Work done = force × distance

work done by the engine = kinetic energy + potential energy + work done friction

kinetic energy due to the car's speed = 1/2mv² = 4468.5 J

potential energy due to the height = mgh = 993 kg × 9.8 m/s² × 0.6 m = 5838.84 J

work done by friction = 2870 J

work done by engine = 5838.84 J + 2870 J + 4468.5 J = 13177.34 J

7 0
3 years ago
1. A flywheel is suspended by resting the inside of the rim on a horizontal knife edge so that the wheel can swing in a vertical
sammy [17]

Answer: A fly wheel having a mass of 30kg was allowed to swing as pendulum about a knife edge at inner side of the rim as shown in figure.

Explanation:

8 0
3 years ago
A closed, rigid, 0.50 m^3 tank is filled with 12 kg of water. The initial pressure is p1 = 20 bar. The water is cooled until the
fgiga [73]

Answer:

X1= 41%

heat transfer = -3450.676 KJ

Explanation:

To get the properties for pure substance in a system we need to know at least to properties. These are usually pressure and temperature because they’re easy to measure. In this case we know the initial pressure (20 bar) which is not enough to get all the properties, but they ask to determine quality, this a property that just have meaning in the two-phase region (equilibrium) so with this information we can get the temperature of the system and all its properties.

There is another property that we can calculate from the data. This is the specific volume. This is defined as \frac{volume}{mass}. We know the mass (12 Kg) and we can assume the volume is the volume of the tank  (0.5 m^{3}) because they say that the tank was filled.  

With this we get a specific volume of  

Specific volume = \frac{0,5 m^{3}}{ 12 kg}= 0.04166667 \frac{m^{3}}{Kg}

From the thermodynamic tables we can get the data for the saturated region with a pressure of 20 bar.

Temperature of saturation = 212.385 °C  

Specific volume for the saturated steam (vg) = 0.0995805 \frac{m^{3}}/{Kg}[\tex]Specific volume for the saturated liquid (vf)= 0.00117675 [tex]\frac{m^{3}}/{Kg}[\tex] The specific volume that we calculate before 0.04166667 m^3/Kg is between 0.00117675 m^3/Kg and 0.0995805 m^3/Kg so  we can be sure that we are in two-phase region (equilibrium).The quality (X) is defined as the percentage in mass of saturated steam in a mix (Two-phase region) The relation between specific volume and quality is  [tex]v = (1-x)*v_{f} + x*v_{g}[\tex]  where  v in the specific volume in the condition (0.04166667 m^3/Kg)  vf = Specific volume for the saturated liquid (0.00117675 m^3/Kg)vg = Specific volume for the saturated steam (0.0995805 m^3/Kg)x = qualityclearing the equation we get:[tex]X = \frac{(v-v_{f})}{(v_{g}-v_{f})} 

X =\frac{(0.04166667- 0.00117675)}{ (0.0995805 – 0.00117675)} = 0.411

The quality is 41%

To calculate the heat transfer we use the next equation.  

Q = m * Cp * delta T  

Where  

Q = heat transfer (Joules, J)

m= mass of the substance (g)

Cp = specific heat (J/g*K) from tables  

Delta T = change in temperature in K for this equation.  

The mass of the substance is 12 kg or 12000 g for this equation  

Cp from tables is 4,1813 J/g*K. You can find this value for water in different states. Here we are using the value for liquid water.  

For delta T, we know the initial temperature 212.385 °C.

We also know that the system was cooled. Since we don’t have more information, we can assume that the system was cooled until a condition where all the steam condensates so now we have a saturated liquid. Since we know the pressure (4 bar), we can get the temperature of saturation for this condition from the thermodynamics tables. This is 143.613 °C, so this is the final temperature for the system.  

T(K) = T°C +273  

T1(K) = 212.385 + 273.15 = 485.535 K

T2 (K) = 143.613 +273.15= 416.763 K

Delta T (K) = (T2-T1) =416.763 K - 485.535 K = -68.772 K

Now we can calculate Q

Q = 12000g * 4,1813 J/g*K* (-68.772 K) = -3450676.36 J or -3450.676 KJ

Is negative because the heat is transfer from the water to the surroundings

4 0
3 years ago
Other questions:
  • Assuming the point estimate in Problem 6.36 is the true population parameter, what is the probability that a particular assay, w
    15·1 answer
  • Elastic recovery: a. Is the strain that remains in a material when it is deformed plastically, then unloaded. b. Is the strain t
    14·1 answer
  • A small pad subjected to a shearing force is deformed at the top of the pad 0.12 in. The heigfit of the pad is 1.15 in. What is
    7·1 answer
  • Many car companies are performing research on collision avoidance systems. A small prototype applies engine braking that deceler
    15·1 answer
  • Ayden read 84 pages in 2 hours. At that rate, how many pages can he read in 5 hours
    11·2 answers
  • What makes building an airplane while flying so difficult?
    5·1 answer
  • A car of length 15 ft. approaches a signalized intersection at 45 mph when the light changes to yellow. The vehicle is 300 ft. f
    13·1 answer
  • An error was reported in a software program by a user. Before that error can be diagnosed and fixed
    5·2 answers
  • In order to fill a tank of 1000 liter volume to a pressure of 10 atm at 298K, an 11.5Kg of the gas is required. How many moles o
    11·1 answer
  • A radio antenna 326 m in diameter receives a radio signal from a very distant object at perpendicular incidence. The radio signa
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!