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
Ymorist [56]
3 years ago
9

In this exercise, use the following variables : i,lo, hi, and result. Assume that lo and hi each are associated with an int and

that result refers to 0.
Write a while loop that adds the integers from lo up through hi (inclusive), and associates the sum with result.

Your code should not change the values associated with lo and hi. Also, just use these variables : i,lo, hi, and result.
Computers and Technology
1 answer:
Assoli18 [71]3 years ago
7 0

Answer:

result = 0

i = lo

while i <= hi:

       result = result + i

       i += 1

Explanation:

Initialize the <em>result</em> as 0 to hold the summation value.

Since we are asked not to change the value of <em>lo</em> and <em>hi</em>, our loop control variable is <em>i</em> and initially it starts from <em>lo.</em>

Since we are asked to add the number from <em>lo</em> to <em>hi, </em>while loop condition checks it.

While the condition satisfies (during each iteration), the value of <em>i</em> is added to the result and the value of <em>i</em> is incremented by one.

You might be interested in
explain the following joke: “There are 10 types of people in the world: those who understand binary and those who don’t.”
BigorU [14]

It means that there are people  who understand binary and those that do not understand it. That is, binary is said to be the way that computers are known to express numbers.

<h3>What is the joke about?</h3>

This is known to be a popular  joke that is often  used by people who are known to be great savvy in the field of mathematics.

The joke is known to be one that makes the point that a person is implying that the phrase is about those who only understands the decimal system, and thus relies on numbers in groups of 10.

The binary system is one that relies on numbers that are known to be  in groups of 2.

Therefore, If the speaker of the above phrase is one who is able to understand binary, that person  would  be able to say that that the phrase  is correctly written as  "there are 2 types of people that understand binary".

Learn more about binary from

brainly.com/question/21475482

#SPJ1

8 0
2 years ago
Data redundancy should be avoided because it wastes storage space and might cause inconsistencies within the database. _________
Ivanshal [37]

The answer is true. Data redundancies should be avoided, because redundancy of information or encoded data, may cause inconsistencies within the database itself and the system and also redundant information can consume a lot of storage space and will just waste it, which is why it is important to avoid data redundancy.

5 0
3 years ago
What does IP stand for (as in IP address)? Also, what is overtype mode?
tino4ka555 [31]
An  IP address is mostly for your WIFI . Internet Protocol . 

Overtype Mode is where you are making changes to text (putting in new characters) 
4 0
3 years ago
what is one example of the decomposers taking from the ecosystem and one of them giving to the ecosystem
adelina 88 [10]
Like when a seed drops on the ground, and a bee come to take some honey. It sticks to the bee and where the bee goes, the bee will rub it off and the seed will start to grow.
8 0
3 years ago
Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum
dem82 [27]

Answer:

C++ code for encryption is given below

Explanation:

#include <iostream>

using namespace std;

//functions to encrypt and decrypt

void encrypt(char str[]);

void decrypt(char str[]);

int main(){

char str[200];

bool done = false;

while(!done){

cout << "Enter a string (enter * to stop): ";

cin.getline(str, 200);

if(str[0] == '*' && str[1] == '\0')

done = true;

else{

encrypt(str);

cout << "Encrypted: " << str << endl;

decrypt(str);

cout << "Decrypted: " << str << endl;

}

cout << endl;

}

}

void encrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] += i;

i++;

if(i == 11)

i = 1;

}

}

void decrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] -= i;

i++;

if(i == 11)

i = 1;

}

}

3 0
3 years ago
Other questions:
  • 2. To learn the proper way to set up a table of contents, editors can use a A. style manual. B. dictionary. C. grammar checker.
    15·1 answer
  • printStars is a method that accepts a single int argument and returns no value. It prints as many stars as indicated by its argu
    9·1 answer
  • Code the function (insertNth list N insValue) which constructs a new list by inserting the specified insValue into the list afte
    6·1 answer
  • How do you activate the Slicer Tools contextual tab?
    13·1 answer
  • When parallel sections of oxygen and fuel gas hoses are taped together, only _____ inches out of 12 inches should be covered by
    8·2 answers
  • Which of the following is NOT true about a savings account
    9·1 answer
  • Which of the following is a common sense safety procedure that can help prevent electrical accidents?
    15·1 answer
  • Write a function that receives three StaticArrays where the elements are already i n sorted order and returns a new Static Array
    11·1 answer
  • Identify the calculation performed by the following code.
    7·1 answer
  • How has the internet improved business communication worldwide
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!