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
g A thin-walled pressure vessel 6-cm thick originally contained a small semicircular flaw (radius 0.50-cm) located at the inner
galben [10]

This question is not complete, the complete question is;

A thin-walled pressure vessel 6-cm thick originally contained a small semicircular flaw (radius 0.50-cm) located at the inner surface and oriented normal to the hoop stress direction. Repeated pressure cycling enabled the crack to grow larger. If the fracture toughness of the material is 88 Mpam^\frac{1}{2} , the yield strength equal to 1250 MPa, and the hoop stress equal to 300 MPa, would the vessel leak before it ruptured

Answer:

length of crack is 5.585 cm

we will observe that, the length of crack (5.585 cm) is less than the vessel thickness (6 cm) Hence, vessel will not leak before it ruptures

Explanation:

Given the data in the question;

vessel thickness = 6 cm

fracture toughness k = 88 Mpam^\frac{1}{2}

yield strength = 1250 MPa

hoop stress equal = 300 MPa

we know that, the relation between fracture toughness and crack length is expressed as;

k = (1.1)(2/π)(r√(πa))  

where k is the fracture toughness, r is hoop stress and a is length of crack

so we rearrange to find  length of crack

a = 1/π[( k / 1.1(r)(2/π)]²

a = 1/π[( kπ / 1.1(r)(2)]²

so we substitute  

a = 1/π [( 88π / 1.1(300)(2/π)]²    

a = 1/π[ 0.1754596 ]

a = 0.05585 m

a = 0.05585 × 100 cm

a = 5.585 cm  

so, length of crack is 5.585 cm

we will observe that, the length of crack (5.585 cm) is less than the vessel thickness (6 cm) Hence, vessel will not leak before it ruptures

8 0
3 years ago
A liquid jet vj of diameter dj strikes a fixed cone and deflects back as a conical sheet at the same velocity. find the cone ang
dmitriy555 [2]

Answer:

lol i cant real it sorry

Explanation:

7 0
2 years ago
What engine does the Mercedes 400e have?
Verdich [7]

Answer:

4.2 m119

Explanation:

it has the 4.2 m119 v8 engine with a top speed of 155 mph and 0 - 60 mph in 6.2 seconds

4 0
3 years ago
Can u say what’s this
tatuchka [14]

Answer:

particles of a solid object packed together

7 0
3 years ago
Read 2 more answers
The electron concentration in silicon at T = 300 K is given by
puteri [66]

Answer:

E=1.44*10^-7-2.6exp(\frac{-x}{18} )v/m

Explanation:

From the question we are told that:

Temperature of silicon T=300k

Electron concentration n(x)=10^{16}\exp (\frac{-x}{18})

                                        \frac{dn}{dx}=(10^{16} *(\frac{-1}{16})\exp\frac{-x}{16})

Electron diffusion coefficient is Dn = 25cm^2/s \approx 2.5*10^{-3}

Electron mobility is \mu n = 960 cm^2/V-s \approx0.096m/V

Electron current density Jn = -40 A/cm^2 \approx -40*10^{4}A/m^2

Generally the equation for the semiconductor is mathematically given by

Jn=qb_n\frac{dn}{dx}+nq \mu E

Therefore

-40*10^{4}=1.6*10^{-19} *(2.5*10^{-3})*(10^{16} *(\frac{-1}{16})\exp\frac{-x}{16})+(10^{16}\exp (\frac{-x}{18}))*1.6*10^{-19}*0.096* E

E=\frac{-2.5*10^-^7 exp(\frac{-x}{18})+40*10^{4}}{1.536*10^-4exp(\frac{-x}{18} )}

E=1.44*10^-7-2.6exp(\frac{-x}{18} )v/m

7 0
2 years ago
Other questions:
  • Electricity is generated in two forms namely………A. Alternating current and wave form B. Alternating current and basic current C.
    7·2 answers
  • A block is sliding on a level surface of varying materials, and so its effective coefficient of friction is variable, 0.1t, wher
    6·1 answer
  • Calculate the value of ni for gallium arsenide (GaAs) at T = 300 K. The constant B = 3. 56 times 1014 9cm -3 K-3/2) and the band
    9·1 answer
  • The yield of a chemical process is being studied.The two most important variables are thought to be the pressure and the tempera
    9·1 answer
  • You are using a Geiger counter to measure the activity of a radioactive substance over the course of several minutes. If the rea
    6·1 answer
  • Argon is compressed in a polytropic process with n = 1.2 from 100 kPa and 30°C to 1200 kPa in a piston–cylinder device. Determin
    14·1 answer
  • 1. Asphyxiation is a hazard posed by Compressed Natural Gas (CNG) vehicles and can be detected when you notice
    7·1 answer
  • Which of the following is an example of a social need?
    5·1 answer
  • ____________ is the organization that oversees environmental compliance.
    14·1 answer
  • Construct a link mechanism of crank oa 30mm rotating clockwise rod ab 100mm and bc 50mm
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!