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
6.48 programming project 1: encode/decode tic -tac-toe
natita [175]

Answer:

What do you need help with?

Explanation:

5 0
3 years ago
The combustion chamber has different shapes depending on the make and model of the engine. True or false
Alisiya [41]

Answer:

svdsdfdfsdfssdf

Explanation:

fsdsdfsdffsdsfdsdf

5 0
3 years ago
A fixed mass of saturated water vapor at 400 kpa is isothermally cooled until it is a saturated liquid. Calculate the amount of
Kazeer [188]
This is the explanation

6 0
3 years ago
When you are climbing a hill on a bike with different speeds, why does it seem like you are pedaling a lot to cover a short dist
ololo11 [35]

It seems like your pedaling a lot because it takes more energy and is way slower than a regular road. It you switch to the higher gear it will make you go slower because it is made for going down hill or going high speeds and a lower gear will help you more cause its easier and it will make it go faster.

5 0
3 years ago
The Reynolds number is a dimensionless group defined for a fluid flowing in a pipe as Re Durho/μ whereD is pipe diameter, u is f
Gala2k [10]

Answer:

the flow is turbulent

Explanation:

The Reynolds number is given by

Re=ρVD/μ

where

V=fluid speed=0.48ft/s=0.146m/s

D=diameter=2.067in=0.0525m

ρ=density=0.805g/cm^3=805Kg/m^3

μ=0.43Cp=4.3x10^-4Pas

Re=(805)(0.146)(0.0525)/4.3x10^-4=14349.59

Re>2100  the flow is turbulent

Note: if you do not want to use a calculator you can use the graphs to calculate the Reynolds number according to their properties

8 0
3 years ago
Other questions:
  • . A storm sewer is carrying snow melt containing 1.200 g/L of sodium chloride into a small stream. The stream has a naturally oc
    8·1 answer
  • If a steel cable is rated to take 800-lb and the steel has a yield strength of 90,000psi, what is the diameter of the cable?
    12·1 answer
  • Write a method called compFloat5 which accepts as input two doubles as an argument (parameter). Write the appropriate code to te
    9·1 answer
  • Two parts are to be assembled in a way that if one part fails, the entire assembly fails. Each of the parts have undergone exten
    15·1 answer
  • The collar A, having a mass of 0.75 kg is attached to a spring having a stiffness of k = 200 N/m . When rod BC rotates about the
    15·1 answer
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • Compared with space operations specialists, intelligence officers are which of the following?
    7·1 answer
  • Please what is dif<br>ference between building technology and building engineering.​
    14·2 answers
  • Factors such as brake shoe orientation, pin location, and direction of rotation determine whether a particular brake shoe is con
    12·1 answer
  • Question 2: (a) In your own words, clearly distinguish and differentiate between Ethics in Engineering and Ethics in Computing (
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!