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
Write a SELECT statement that returns the same result set as this SELECT statement. Substitute a subquery in a WHERE clause for
sergiy2304 [10]

Answer:

SELECT distinct VendorName FROM Vendors

WHERE VendorID IN (

SELECT VendorID FROM Invoices

)

Explanation:

6 0
3 years ago
Do plastic materials have high or low ductility? Explain why.​
Flura [38]
The impact behavior of plastic materials is strongly dependent upon the temperature. At high temperatures, materials are more ductile and have high impact toughness. At low temperatures, some plastics that would be ductile at room temperature become brittle.
3 0
2 years ago
Answer the following either true (T) or false (F) (5 pts)
likoan [24]

Answer:

1. True

2. True

3. False

Explanation:

The office location is where the soil layer is not uniform. The thickness of the soil varies which could lead to doors being jammed. The engineer needs to estimate the differential in clay soil.

The inclined surface can hold less weight than a vertical surface. The capacity to hold the weight is due to the gravitational force which is exerted to the load.

6 0
3 years ago
List the three parts of an atom in the Bohr Model
gogolik [260]
Structure Of The Atom: Our current model of the atom can be broken down into three constituents parts – protons, neutron, and electrons. Each of these parts has an associated charge, with protons carrying a positive charge, electrons having a negative charge, and neutrons possessing no net charge.
7 0
3 years ago
What is clearance? What is backlash? What is interference? Explain briefly.
Anton [14]

Explanation:

Clearance:

For easy matching  and dis matching  of  hole and  shaft we use size of hole little bit more than the size of shaft and this difference in size is called clearance.

Backlash:

  It is the clearance between the two mating gear to avoids failure of gears.Actually when temperature of gears increases then at the same time the size of gear also increases ,due this there is a possibility foe jamming of gears so to avoids this backlash is provides.

Interference:

  When two gears are matting then addendum of one gear inters into the deddendum of another gear and due to this gears get jam .This phenomenon is called interference.

5 0
3 years ago
Other questions:
  • If the specific surface energy for aluminum oxide is 0.90 J/m2 and its modulus of elasticity is (393 GPa), compute the critical
    11·1 answer
  • Consider a Mach 4.5 airflow at a pressure of 1.25 atm. We want to slow this flow to a subsonic speed through a system of shock w
    15·1 answer
  • Multiple Choice
    11·1 answer
  • Draw a flowchart to represent the logic of a program that allows the user to enter values for the current year and the user’s bi
    14·1 answer
  • 53. The plan of a building is in the form of a rectangle with
    13·1 answer
  • In a CNC machining operation, the has to be moved from point (5, 4) to point(7, 2)along a circular path with center at (7,2). Be
    5·1 answer
  • Technician A says that reinforcements may be made of plastic.
    6·1 answer
  • Which battery produces more volts per cell, maintenance type or maintenance free ?
    6·1 answer
  • A light aircraft with a wing area of 200 ft^2 and a weight of 2000 lb has a lift coefficient of 0.39 and a drag coefficient of 0
    14·1 answer
  • What lump sum of money must be deposited in a bank account at present time so that Php 500 monthly can be withdrawn for five yea
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!