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
When you add encryption to a powerpoint presentation what does it do
abruzzese [7]

Answer: your document will be inaccessible

5 0
2 years ago
Coding with Loops Worksheet
BartSMP [9]

Answer:

if you give me brainliest i will answer your question

Explan

4 0
2 years ago
Read 2 more answers
Gary lives in an area that receives high rainfall throughout the year. Which device would be useful to him to maintain his compu
-BARSIC- [3]

The correct answer is B.UPS

A UPS or Uninterruptable Power supply makes sure that you have backup in case there is a power outage in your area. It provides ample time for you to save all files before shut down.

6 0
3 years ago
Read 2 more answers
Respond to the following in three to five sentences. Select one netiquette guideline. Explain how this helps you draft more effe
slamgirl [31]

Answer:

Keeping as few emoji's as possible. This helps because lots of emoji's can make things confusing and/or annoying. This just means being kind to the person you're messaging and not making things confusing.

8 0
3 years ago
I WILL GIVE BRAINLIEST
Lostsunrise [7]

Answer:

i know but you to help me ok this answer b

3 0
3 years ago
Other questions:
  • Which company provides the Loki Wi-Fi mapping service?
    10·1 answer
  • "You are setting up a new subnetwork on an existing network. Management has asked that you use existing cabling that the company
    14·1 answer
  • Which of the following methods is the easiest way to set up a VPN client on a computer for a user who is not technical?
    12·1 answer
  • __________ refers to rules, statutes, codes, and regulations established to provide a legal framework within which business may
    13·1 answer
  • In addition to using comments and track changes, you can also use the comparison feature for reviewing documents. In this activi
    11·1 answer
  • An application with which you can perform calculations on numbers and work with other data
    8·1 answer
  • True or false? The History list shows only Web pages you visited during the current computing session. -computer essentials
    7·1 answer
  • Any material that comes into contact with the body must be __________.
    6·1 answer
  • What problems do you see in the process of transacting business online
    10·1 answer
  • Jazmine just finished setting up an operating system that's designed to work between a VM guest OS and computer hardware. What i
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!