answer.
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
Andrej
2 months ago
10

Assume the int variables i,lo, hi, and result have been declared and that lo and hi have been initialized. Assume further that r

esult has been initialized to the value 0. Write a for loop that adds the integers from lo up through 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:
zubka84 [1K]2 months ago
5 0

Answer:

#include <iostream>

using namespace std;

int main() {

   int i, lo=12, hi=45, result=0; // initializing the required variables..

   for(i=lo;i<=hi;i++) // implementing a for loop.

   {

       result+=i; // accumulating the sum of integers..

   }

   cout<<result<<endl; // displaying the resulting total.

return 0;

}

Output:-

969

Explanation:

This program is written in C++. Initially, the variables i, lo, hi, and result are declared, with only lo, hi, and result initialized. A for loop is employed to loop through all values from lo to hi, adding each integer to the result.

You might be interested in
Write the pseudocode that determines the change to be dispensed from a vending machine. An item in the machine can cost between
Amiraneli [1052]

Answer:

input price

set change to one hundred minus price

set quarter to change divided by 25

set change to change mod 25

set dime to change divided by 10

set change to change mod 10

set nickel to change divided by 5

set change to change mod 5

set penny to change

print "You acquired an item for price cents and paid me a dollar. Your change is: "

if quarter is equal to 1

print quarter

else if quarter is greater than 1

print quarter with "quarters"

if dime is equal to 1

print dime

else if dime is greater than 1

print dime with "dimes"

if nickel is equal to 1

print nickel

else if nickel is greater than 1

print nickel with "nickels"

if penny is equal to 1

print penny

else if penny is greater than 1

print penny with "pennies"

Explanation:

A clearer way to express the pseudocode above could involve using alternative names for change as:

input price

set change to one hundred minus price

set quarter to change divided by 25

set quarter_remainder to change mod 25

set dime to quarter_remainder divided by 10

set dimes_remainder to quarter_remainder mod 10

set nickel to dimes_remainder divided by 5

set nickel_remainder to dimes_remainder mod 5

set penny to nickel_remainder

print "You purchased an item for" price"cents and provided a dollar. Your change is: "

if quarter is equal to 1

print quarter "quarter"

else if quarter is greater than 1

print quarter "quarters"

if dime is equal to 1

print dime "dime"

else if dime is greater than 1

print dime "dimes"

if nickel is equal to 1

print nickel "nickel"

else if nickel is greater than 1

print nickel "nickels"

if penny is equal to 1

print penny "penny"

else if penny is greater than 1

print penny "pennies"

Next, I will illustrate the pseudocode through an example:

Let's assume price = 75

Thus, change = 100 - price = 100 - 75 = 25

change = 25

quarter = change/25 = 25/25 = 1

quarter = 1

quarter_remainder = change % 25 = 25%25 = 0

dime = 0/10 = 0

At this point, all additional values are 0.

The following message will be displayed on the screen:

You acquired an item for 75 cents and paid me a dollar. Your change is:

Now the program proceeds to the conditional statement

if quarter == 1

This condition holds true because the value of quarter is 1

print quarter "quarter"

Subsequently, this line will appear on the screen:

1 quarter

Thus, the full output of the pseudocode is:

You acquired an item for 75 cents and paid me a dollar. Your change is:

1 quarter

6 0
1 month ago
A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
zubka84 [1067]
The answer is back up
8 0
1 month ago
Read 2 more answers
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
zubka84 [1067]

Answer:

The code placed where "/*Your solution goes here */" is as follows:

while(numInsects<200) // while loop

       {

            System.out.print(numInsects+" "); // output statement

            numInsects=numInsects*2; // operation to double the value.

       }

Output:

  • If the input is 16, the result is 16 32 64 128.
  • If the input is 25, the result is 25 50 100.

Explanation:

  • The above Java code fills the section designated as "Your solution" and will operate correctly.
  • The program accepts a user input and continues to print double the value until it reaches 200 or more.
  • The while loop evaluates whether the value remains below 200. If so, the operation proceeds; otherwise, it stops.
5 0
2 months ago
Which of the following describes ETL? a) A process that transforms information using a common set of enterprise definitions b) A
zubka84 [1067]

Answer:

The right choice is d) All of these options are accurate.

Explanation:

ETL refers to Extract, Transform, and Load. An ETL framework retrieves data from various sources, upholds standards for data quality and consistency, standardizes data so disparate sources can be integrated, and ultimately presents the data in formats suitable for application development and decision-making by end-users.

4 0
2 months ago
Other questions:
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • The part of the computer that contains the brain, or central processing unit, is also known as the A.monitor B.modem C.keyboard
    10·1 answer
  • Marien is using the Council of Science Editors (CSE) style guidelines to write her research paper. What is her most likely topic
    13·1 answer
  • Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input.
    6·1 answer
  • Form the recurrence relations (RRs) for the number of vertices and the number of edges of a hypercube of n dimensions, Hn. Solve
    13·1 answer
  • In 2007, this wireless security algorithm was rendered useless by capturing packets and discovering the passkey in a matter of s
    6·2 answers
  • JAVA Write a program that first asks the user to type a letter grade and then translates the letter grade into a number grade. L
    9·1 answer
  • Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
    14·1 answer
  • Your reputation and credibility will be immediately destroyed if your website contains?
    8·2 answers
  • Social networking sites like Office Online, PayPal, and Dropbox are used to develop social and business contacts.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!