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]
4 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]4 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
Consider the following declaration.int[] beta = new int[3];int j;Which of the following input statements correctly input values
zlopas [31]

Answer:

The answer is "Option (i) and (ii)".

Explanation:

In the given java code an integer array that is "beta" defines that contains 3 elements. To insert element in by user input we use scanner class object that is "cin". In the given question two options are defined that is used for inserting elements in array but there is a minor difference between them that can be described as:  

  • In option (i), To insert an element in array we use index value. It is time taking.
  • In option (ii), In this option use a loop, inside a loop we write only one line, and this line inserts elements in array automatically.
3 0
3 years ago
Which of the following are advantages of a local area network, as opposed to a wide area network? Select 3 options.
Lana71 [14]

Answer:

1. Which of the following are advantages of a <u>wide area network</u>, as opposed to a local area network? Select 2 options.

  • provides access to other networks
  • greater geographic reach

1. Which of the following are advantages of a <u>local area network</u>, as opposed to a wide area network? Select 3 options.

  • more secure
  • lower cost
  • higher speeds

2. Which of the following are advantages of a <u>wide area network</u>, as opposed to a local area network? Select 2 options.

  • provides access to other networks
  • greater geographic reach

Explanation:

3 0
3 years ago
The type of business organization that can continue indefinitely is known as a
Natasha2012 [34]
C. Corporation

Corporation- The type of business organization that can continue indefinitely
6 0
3 years ago
Which of the following should be clicked to open Backstage View?
lora16 [44]

Answer:

File tab

Explanation:

source https://www.computerhope.com/jargon/b/backstage-view.htm

7 0
3 years ago
Read 2 more answers
A child with suspected sleep apnea was given an apnea monitoring device to use over the next month. The device was capable of re
Hoochie [10]

I guess the correct answer is 94774

In thе CPT® Indеx lοοk fοr Mοnitοring/Pеdiatric Apnеa and yοu arе dirеctеd tο cοdе rangе 94774-94777.  Cοdе sеlеctiοn is basеd οn thе cοmpοnеnts οf thе tеst pеrfοrmеd.  In this casе, cοdе 94774 dеscribеs thе data stοragе capability, including thе prοvidеr οr οthеr qualifiеd hеalth carе prοfеssiοnal intеrprеtatiοn and rеpοrt.  Thе cοdе is tο bе rеpοrtеd еach 30-day pеriοd.

6 0
3 years ago
Other questions:
  • Conventional prescription eyeglasses are considered sufficient PPE for eye protection. A) True B) False
    11·1 answer
  • A university wants to install a client-server network. Which feature do you think is important for them as they set up the netwo
    8·1 answer
  • 15 points
    5·2 answers
  • A company is updating their office routers that handle all incoming and outgoing networking traffic. They would like the PCs to
    10·1 answer
  • __________ refers to the idea that eachemployee should report
    14·1 answer
  • Which army regulation would be referenced if you want to properly mark removable ais storage media?
    6·1 answer
  • Why do filmmakers release trailers?
    5·2 answers
  • PLEASE HELP I WILL GIVE BRAINLIEST!!
    8·1 answer
  • Which of the following commands should be used if a user does NOT want the header which has been created to appear on the first
    13·1 answer
  • Trade Periodicals are usually highly scholarly resources<br> True<br><br> False
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!