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
State five applications of thermochromic materials
rusak2 [61]

Explanation:

The end-use industries of thermochromic materials include packaging, printing & coating, medical, textile, industrial, and others. Printing & coating is the fastest-growing end-use industry of thermochromic materials owing to a significant increase in the demand for thermal paper for POS systems. The use of thermochromic materials is gaining momentum for interactive packaging that encourages consumers to take a product off the shelf and use it.

8 0
3 years ago
What is made in heaven?​
kramer

Answer:

Babies come from heaven didn't you know?

3 0
3 years ago
**Please Help ASAP**
RoseWind [281]

Answer:

look up the assignment number. its in the left side of the screen. its what i did when i had problems.

Explanation:

6 0
3 years ago
What is the difference between science and engineering?
jek_recluse [69]

Answer:

The following table is among some of the discrepancies between some of the different topics.

Explanation:

  • Science seems to be the application of structured organized facts which could be interpreted scientifically because when engineering would be a branch of science which deals with either the profession of acquiring including using technological, computational, economical and severity of adverse effects to design and manufacture equipment and devices that seem to be beneficial to mankind.
  • Science would be a set of information and established frameworks whereas the use of these models and information to construct structures as well as mechanisms becomes engineering.
4 0
3 years ago
Consider the following fragment of code in an authentication program:
Juli2301 [7.4K]

Answer:

Backdoor

Explanation:

The back door fragment in a program allows user to access backdoor information without necessarily following the common security procedures needed. In this case, once the programmer keys in the username he or she logs in without putting password. Therefore, this is a backdoor fragment.

8 0
4 years ago
Other questions:
  • . Consider the single-engine light plane described in Prob. 2. If the specific fuel consumption is 0.42 lb of fuel per horsepowe
    9·1 answer
  • A distillation column is initially designed to separate a mixture of toluene and xylene at around ambient temperature (say, 100°
    13·1 answer
  • Tech A says that a gear set that has a drive gear with 9 teeth and a driven gear with 27 teeth has a gear ratio of 3:1. Tech B s
    7·1 answer
  • A square loop of wire surrounds a solenoid. The side of the square is 0.1 m, while the radius of the solenoid is 0.025 m. The sq
    6·1 answer
  • Electrical pressure or “force”<br><br> A) current<br> B) resistance <br> C) voltage
    6·1 answer
  • Are you able to text without looking at your phone?
    10·1 answer
  • "Mass burn technology uses unprocessed municipal solid waste to generate heat which is used to produce electricity."
    9·2 answers
  • If a particle moving in a circular path of radius 5 m has a velocity function v = 4t2 m/s, what is the magnitude of its total ac
    15·2 answers
  • In contouring, it is necessary to measure position and not velocity for feedback.
    9·1 answer
  • Why do stores still sell those 1.5 volt batteries that are like three times the size of other 1.5 volt batteries. What is the po
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!