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
What is the average linear (seepage) velocity of water in an aquifer with a hydraulic conductivity of 6.9 x 10-4 m/s and porosit
jeka94

Answer:

a. 0.28

Explanation:

Given that

porosity =30%

hydraulic gradient = 0.0014

hydraulic conductivity = 6.9 x 10⁻4 m/s

We know that average linear velocity given as

v=\dfrac{K}{n_e}\dfrac{dh}{dl}

v=\dfrac{6.9\times 10^{-4}}{0.3}\times0.0014\ m/s

v=3.22\times 10^{-6}\ m/s

The velocity in m/d      ( 1 m/s =86400 m/d)

v= 0.27 m/d

So the nearest answer is 'a'.

a. 0.28

4 0
3 years ago
Which of the following answer options are your employer's responsibility?
tino4ka555 [31]

Answer:

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

Explanation:

To find - Which of the following answer options are your employer's responsibility?  Select all that apply.

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

Solution -

The correct options are -

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

All are the Responsibilities of an employer

Reason -

The most important duty of the employer is to stay alert and implement a correctly and efficiently written communication program related to hazards of the substances in the workplace.

He also has to maintain the program so that employees do not get affected.

3 0
3 years ago
Which option distinguishes the step in the engineering design phase described in the following scenario?
rewona [7]

Answer:

reasearching the problem

Explanation:

EDG

7 0
3 years ago
A(n) ____ is an object setting used to control the visible display of objects.
KatRina [158]
Remote?? maybe I’m not really sure
3 0
3 years ago
Find three examples of good websites and three examples of bad websites. List them below, and in a
Fudgin [204]

Answer: its c

Explanation:

4 0
3 years ago
Other questions:
  • what are the characteristics of an ideal fluid the general relation between shear stress and velocity gradient​
    10·1 answer
  • I need help!!! Because this is due
    14·2 answers
  • How to code the round maze in CoderZ?
    5·1 answer
  • Add my sc please?.<br><br> kindacracked
    12·2 answers
  • Which of the following describes a polar orbit?
    7·1 answer
  • How many buttons in an airbus a380 cockpit
    9·2 answers
  • A fusible link should be how many wire sizes smaller than the actual circuit wire?
    8·1 answer
  • (a) A non-cold-worked 1040 steel cylindrical rod has an initial length of 100 mm and initial diameter of 7.50 mm. is to be defor
    7·1 answer
  • Q1: The first option should always be to get out safely (RUN)
    6·1 answer
  • In what type of automobile is a transaxle most commonly found?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!