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
IgorC [24]
3 years ago
9

Assume the int variables i, lo, hi, and result have been declared and that lo and hi have been initialized. Write a for loop tha

t adds the integers between lo and hi (inclusive), and stores the result in result. Your code should not change the values of lo and hi. Also, do not declare any additional variables -- use only i, lo, hi, and result.NOTE: just write the for loop header; do not write the loop body itself.
Computers and Technology
1 answer:
hram777 [196]3 years ago
3 0

Answer:

for (i = lo, result = 0; i <= hi; result += i, i++) {}

Explanation:

A for loop header has three statements:

  1. <em>i = 0, result = 0;     </em>This statement initializes <u>i</u> and <u>result</u> variables with 0. It is executed only once at the very start of the for loop.
  2. <em>i <= hi;</em>     This statement is executed after the first statement and again after the execution of code in body of the loop.
  3. <em>result += i, i++</em>     This statement is executed after the execution of code in body of the loop but before the execution of second statement.

Therefore, the following sequence of events will occur:

  • The result variable is initialized with 0 at start.
  • Then, the condition is checked. If the value of i will be less than or equal to the value of hi, the third statement will be executed.
  • The third statement will add the value of i to the value of result and then increase the value of i by 1.
  • Then, again the condition in second statement will be checked.

This loop will be executed for as long as the condition remains true.

You might be interested in
1.5 question 3 on edhesieve
morpeh [17]

Answer:

ppl

Explanation:

asfafgdffsghsdfghdgsghdfghtrbd54445 ddfgg

7 0
3 years ago
What do we call exceptions to the exclusive rights of copyright law?
Studentka2010 [4]

Answer:

Fair use

Explanation:

I don't know if this is correct but Its the best option.

4 0
3 years ago
Consider the following code:
Deffense [45]

Answer:

The output of C is 102.

100 + 1 + 1 = 102

8 0
3 years ago
Help me please, I'm begging you
wel

Answer: 7 math 8 many

Explanation: it makes sense

5 0
3 years ago
How to remove duplicates from list in python?
kondaur [170]
<span> the new way of </span>removing duplicates<span> from an iterable while keeping it in the original order </span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • If you paste a word document text into an excel spreadsheet, the paste optio allow you to keep source formatting or
    9·1 answer
  • What is a stereo type?
    14·2 answers
  • A _____ is a machine that changes information from one form into another.
    7·1 answer
  • Complex communication skills will probably never be outsourced to a computer because they require the human touch.
    8·1 answer
  • The function below takes a single parameters: a list of numbers called num_list. Return a new list containing just the three lar
    5·1 answer
  • Select the correct answer.
    6·1 answer
  • ........ is a formal description of message formats and the rules for exchanging those messages
    12·1 answer
  • Write a sentence that describes how a series circuit works.
    15·1 answer
  • Select the correct answer from the drop-down menu.
    15·2 answers
  • Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!