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
A distillation column is initially designed to separate a mixture of toluene and xylene at around ambient temperature (say, 100°
weeeeeb [17]

Answer:

Purchase cost= 87056

Bar module cost= 292725

Explanation:

solution is attached below

6 0
4 years ago
What do you mean by searching?​
nikitadnepr [17]

Answer:

thoroughly scrutinizing, especially in a disconcerting way.

Explanation:

8 0
4 years ago
Write torsion equation and explain the importance of each components.<br>​
Elanso [62]
The equations are based on the following assumptions

1) The bar is straight and of uniform section
2) The material of the bar is has uniform properties.
3) The only loading is the applied torque which is applied normal to the axis of the bar.
4) The bar is stressed within its elastic limit.

Nomenclature

T = torque (Nm)
l = length of bar (m)
J = Polar moment of inertia.(Circular Sections) ( m^4)
J' = Polar moment of inertia.(Non circluar sections) ( m^4 )
K = Factor replacing J for non-circular sections.( m^4)
r = radial distance of point from center of section (m)
ro = radius of section OD (m)
τ = shear stress (N/m^2)
G Modulus of rigidity (N/m^2)
θ = angle of twist (radians)

4 0
3 years ago
A cylinder with a 6.0 in. diameter and 12.0 in. length is put under a compres-sive load of 150 kips. The modulus of elasticity f
jeka94

Answer:

Final Length = 11.992 in

Final Diameter = 6.001 in

Explanation:

First we calculate the cross-sectional area:

Area = A = πr² = π(3 in)² = 28.3 in²

Now, we calculate the stress:

Stress = Compressive Load/Area

Stress = - 150 kips/28.3 in²

Stress = -5.3 ksi

Now,

Modulus of Elasticity = Stress/Longitudinal Strain

8000 ksi = -5.3 ksi/Longitudinal Strain

Longitudinal Strain = -6.63 x 10⁻⁴

but,

Longitudinal Strain = (Final Length - Initial Length)/Initial Length

-6.63 x 10⁻⁴ = (Final Length - 12 in)/12 in

Final Length = (-6.63 x 10⁻⁴)(12 in) + 12 in

<u>Final Length = 11.992 in</u>

we know that:

Poisson's Ratio = - Lateral Strain/Longitudinal Strain

0.35 = - Lateral Strain/(- 6.63 x 10⁻⁴)

Lateral Strain = (0.35)(6.63 x 10⁻⁴)

Lateral Strain = 2.32 x 10⁻⁴

but,

Lateral Strain = (Final Diameter - Initial Diameter)/Initial Diameter

2.32 x 10⁻⁴ = (Final Diameter - 6 in)/6 in

Final Diameter = (2.32 x 10⁻⁴)(6 in) + 6 in

<u>Final Diameter = 6.001 in</u>

8 0
3 years ago
A company buys a machine for $12,000, which it agrees to pay for in five equal annual payments, beginning one year after the dat
Yuki888 [10]

Answer:

$7,778.35

Explanation:

At year 3, the final payment of the remaining balance is equal to the present worth P of the last three payments.

First, calculate the uniform payments A:

A = 12000(A/P, 4%, 5)

= 12000(0.2246) = 2695.2  (from the calculator)

Then take the last three payments as its own cash flow.

To calculate the new P:

P = 2695.2 + 2695.2(P/A, 4%, 2) = 2695.2 + 2695.2(1.886) = 7778.35

Therefore, the final payment is $7,778.35

4 0
4 years ago
Other questions:
  • What are the advantages of using 3D ink jet printing?
    10·1 answer
  • - if `check_1` and `check_2` variables are both True, it should set the value of a variable `outcome` to the string 'BOTH' - eli
    12·1 answer
  • A piston–cylinder device contains a mixture of 0.5 kg of H2 and 1.2 kg of N2 at 100 kPa and 300 K. Heat is now transferred to th
    8·1 answer
  • Which of the following is an example of a computer simulation?
    7·1 answer
  • Which option identifies the requirement standard NOT met in the following scenario?
    13·1 answer
  • 1. A hydro facility operates with an elevation difference of 50 m and a flow rate of 500 m3/s. If the rotational speed is 90 RPM
    12·1 answer
  • Shielding gases are used to protect the molten metal from what?
    13·1 answer
  • a coiled spring is stretched 31.50 cm by a 2.00N weight. How far is it stretched by a 10.00 N weight?
    6·1 answer
  • The only way to know if a design will work in real-world conditions is to build a model, or prototype, based on the plan. This i
    7·2 answers
  • According to Gary Sirota, the proposed Bajagua wastewater treatment plant is a beneficial solution because __________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!