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
Write one for loop to print out each element of the list several things. then write another for loop
Kay [80]

Question:

Write one for loop to print out each element of the list several_things. Then, write another for loop to print out the TYPE of each element of the list several_things.

Answer:

The solution in python is as follows:

for element in several_things:

    print(element)

   

for element in several_things:

    print(type(element))

Explanation:

The solution assumes that the list several_things has already been initialized.

So, the rest of the code is explained as follows:

This line iterates through the list, several_things

for element in several_things:

This line prints each element

    print(element)

This line iterates through the list, several_things for the second time    

for element in several_things:

This line prints the type of each element

    print(type(element))

6 0
3 years ago
Jim has entered the age of each of his classmates in cells A1 through A65 of a spreadsheet.
alexandr402 [8]
The answer to this is B=MODE(A1:A65)
8 0
3 years ago
The date function to apply when you want to display only the current date in the worksheet is the _____ function.
QveST [7]
The answer would be today
4 0
3 years ago
Read 2 more answers
While traveling in India, Sabina notes all of her daily expenses in rupees in her spreadsheet. At the end of the day, she wants
Oxana [17]
One rupee is about .015 of an American dollar. So multiply with how ever many rupee's she had.
6 0
3 years ago
When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs
notsponge [240]

Answer:

See explanation

Explanation:

The question would be best answered if there are list of options.

However, the question is still answerable.

When there's a need to change the value of the argument passed into a function, what you do is that you first pass the argument into a parameter, then you change the value.

Take for instance, the following code segment:.

int changeArg(int n){

int newhange = n;

newhange++;

return newhange;

}

The above takes in n as the argument

Then it passes the value of n into a reference parameter, newchange

And lastly, the value is altered.

3 0
3 years ago
Other questions:
  • What is a technology that exists inside another device called
    11·1 answer
  • 1. Write a bash script to create 3 files of different size greater than 1700 kb and less than 1800 kb . The 2. Content of the fi
    9·1 answer
  • Your friend is overspending and in need of a budget. What type of expense should they reduce next month?
    10·2 answers
  • What is distribution hardware?
    14·1 answer
  • What are the primary benefits of relying on systems development standards?
    7·1 answer
  • Should I Buy a 2070 super or 2060 super
    6·1 answer
  • How much time per day does the average U.S. youth spend watching television, playing video games, or using a computer?
    8·1 answer
  • Anyone watch anime, i love stay kids and they sang the op for Tower of God XD
    8·2 answers
  • Someone help meeeeeeeee plz.......................
    11·2 answers
  • A Network Intrusion Detection System watches for potentially malicious traffic and _______ when it detects an attack.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!