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
nevsk [136]
3 years ago
15

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.
Computers and Technology
1 answer:
IRISSAK [1]3 years ago
4 0

Answer:

result=0;

for (i=lo ; i<=hi; i++){

result += i;

}

Explanation:

The question says result was declared but not initialized, so using result without initializing it to 0 would throw an error as result would be undefined and you can't add a number to undefined

Another way to do it to keep everything inside the loop would be

for (i=lo ; i<=hi; i++){

if (i==lo) result= 0;

result += i;

}

but this is impractical since it would add unnecesary operations in each cycle of the loop

You might be interested in
If you have two tasks x and y, with y being a successor to x, if we mark x as undone (because it needs to be redone for some rea
Ierofanga [76]

Answer:

idk

Explanation:

sorry

7 0
3 years ago
Robert's got a quick hand
Alina [70]
verry
good
song
love
it
6 0
3 years ago
Read 2 more answers
What is heaven backwards?
sweet-ann [11.9K]
It is Nevaeh backwards hope that helps! :3 and feel free to pm me if you have anymore questions! :3
5 0
3 years ago
Read 2 more answers
What are the six peripherals of a computer system
Lubov Fominskaja [6]
Peripherals fall into three categories:
1. input devices are devices that put commands inside computers such as keyboards, mouses, and joysticks but the first two are the mostly used nowadays
2. output devices are what computers give out such as monitors, printers, speakers and I think projectors also fall into that category
3.storage devices such as a optical drive, hard drive, SDD, flash drive
So the main ones might be a mouse, keyboard, monitors, I think printers, hard drives and flash drives but speakers might be considered as one instead of a flash drive.

4 0
3 years ago
List of bad websites and why
r-ruslan [8.4K]

Penny Juice – bad design examples.

Blinkee website – bad design example.

Great Dreams I — bad designed website.
8 0
3 years ago
Other questions:
  • Which kind of software allows users to draw pictures, shapes, and other graphical images with various on-screen tools such as a
    14·1 answer
  • To edit the color of the text in presentation software, choose the Font color command Text Color in the ________ ribbon toolbar.
    15·2 answers
  • When a person or organization uses the services of another professional, that person or organization is called the _______
    15·1 answer
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • Based on the code you created in this Unit, propose a way to re-use most of the code (with different information in the variable
    14·1 answer
  • Juan has performed a search on his inbox and would like to ensure the results only include those items with attachments which co
    14·2 answers
  • If I am working in a document and wish to follow a hyperlink, what should I do?
    7·1 answer
  • Help plz. due yesterday
    13·1 answer
  • Which layer of the OSI model provides a user interface in the form of an entry point for programs to access the network infrastr
    10·1 answer
  • Which tool uses images and other visual elements to provide artistic
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!