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 student lives in an apartment with a floor area of 60 m2 and ceiling height of 1.8 m. The apartment has a fresh (outdoor) air
USPshnik [31]

Answer:

4

Explanation:

5 0
2 years ago
For somebody
Brums [2.3K]

Answer:

Cool song

Explanation:

Ur hot also

4 0
2 years ago
A teacher tells her​ students, "When you do your math homework​ assignments, you must use white lined paper.​ Please, no​ tear-o
Sindrei [870]

Answer:

The white lined paper

Explanation:

The teacher is most likely putting the while line paper in jeopardy because of the detail process involved in taking care of the paper prior to the submission of the home work.

The fact that a mistake must not be visible due to the instruction of every erasures being thorough and clean.  this can cause jeopardy to the paper.

8 0
3 years ago
A mixing basin in a sewage filtration plant is stirred by a mechanical agitator with a power input/WF L T=. Other parameters de
MakcuM [25]

Answer: π= G[√(u.V/W)]

STEP 1

Given parameters:

Power Input W= FL/T,

Absolute Viscosity u= FT/L²

Basin volume V= V/L³

Velocity gradient G= V/L³

STEP 2

We start by expressing the velocity gradient G as a function of W, u, V

G= G(W,u,V)

To get the pii terms, we use the dimension number formula n=k - r

where n and k are natural numbers representing number of fundamental dimensions and variable present respectively.

n= 4-3=1

STEP 3:

We expressed the pii terms as

π= G.W^a.u^b.V^c

The three fundamental F L T

We can write as

Fⁿ.Lⁿ.Tⁿ= 1/T. (FL/T)^a.(FT/L²)^b.(L³)

Using the exponential rule and by comparing coefficient on both sides;

Fⁿ.Lⁿ.Tⁿ= F^a+b. L^a-2b+3c. T^-a+b-1

Fⁿ= F^a+b = a+b= 0..............I

Lⁿ= L^a-2b+3c=0 = a-2b+3c=0...........ii

Tⁿ=L^-a+b-1=0. -a+b-1=0............iii

From the above equations we have,

a+b =0: b=-a...........iv

putting eq. iv into iii , we have

-a-a-1=0: -2a-1=0: a= -1/2

substituting the above value of a into eq iv, we have

b= 1/2

substituting the value of b above into eq 2, we have,

-1/2-2(1/2)+3c=0

c=1/2.

Lastly, from the pii terms given above we can obtain dimensionless relationship,

π=G(W^-1/2.u^1/2.V^1/2)

We can write this as

π= G[ √1/W.√u. √1/2] = G[(√u.V/√W)] or G[√(u.V/W)].... final answer.

5 0
3 years ago
A step-down transformer (turns ratio = 1:7) is used with an electric train to reduce the voltage from the wall receptacle to a v
SOVA2 [1]

Answer:

wait lemme check it out

Explanation:

6 0
3 years ago
Other questions:
  • The y-component of velocity for a certain 2-D flow field is given as u = 3xy + x2 . Determine the x-component of velocity if the
    12·1 answer
  • How to identify this fossil
    9·1 answer
  • Refrigerant 134a enters a horizontal pipe operating at steady state at 40°C, 300 kPa, and a velocity of 25 m/s. At the exit, the
    11·1 answer
  • Write a program that uses while loops to perform the following steps: Step a: Prompt the user to input two integers: firstNum an
    12·1 answer
  • An inventor claims to have developed a heat engine that produces work at 10 kW, while absorbing heat at 10 kW. Evaluate such a c
    12·1 answer
  • How did humans create a space suit without ever going. How did we know spaces conditions?
    5·2 answers
  • El protozoos es del reino protista?
    14·2 answers
  • Consider a machine of mass 70 kg mounted to ground through an isolation system of total stiffness 30,000 N/m, with a measured da
    9·1 answer
  • Does an electronic clock use electrical energy?​
    10·2 answers
  • What is Join..?? Explain different types of joins.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!