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
fgiga [73]
3 years ago
6

Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have alre

ady been declared, use a while loop to compute the sum of the cubes of the first n counting numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 2*2*2 3*3*3 4*4*4 into total. Use no variables other than n, k, and total. Do NOT modify n.
Computers and Technology
1 answer:
Fudgin [204]3 years ago
4 0

Answer:

The c++ program to implement the while loop is given below.

#include <iostream>

using namespace std;

int main() {

  // declaration of integer variables

   int k, n, total;

   // initialization of integer variables

   k=1, n=4, total=0;

//  loop executed till value of k becomes equal to value of n

   while( k <= n ){

       // cube of every integer is added to the variable total

       total = total + ( k * k * k );

       // value of k is incremented to go to the next number

k = k + 1 ;

   }  

   return 0;

}  

Explanation:

The program begins with the declaration of integer variables.  

int k, n, total;

This is followed by initialization of these variables.

k=1, n=4, total=0;

The while loop runs over the variable k which is initialized to 1. The loop runs till value of k reaches the value of integer n.

First, cube of k is computed and added to the variable total.

After first execution of the loop, total is initialized to the cube of 1.

Next, value of variable k is incremented by 1 so that k is initialized to next integer.

After first execution of the loop, k is incremented from 1 to 2.

while( k <= n )

{

total = total + ( k * k * k );

k = k + 1 ;

   }

When the value of k reaches the value of integer n, the cube of n is calculated and added to the variable, total.

When k is incremented, it becomes more than n and hence, loop gets terminated.

As the return type of main is int, the program terminates with the statement shown below.

return 0;

No output is displayed as it is not mentioned in the question.

No user input is taken as it is mentioned that integer variables are already initialized.

You might be interested in
PLEASE HELP<br>what are some benefits of using graphic on web page?​
qwelly [4]

Images help tell a story where describing with words is either too lengthy, or practically impossible. For instance, you could have a map of a location and various arrows and other markings to describe movements of troops during a battle of the civil war. This is one example of many that you could have as an image on a website. Describing the troop movements with words only may be really difficult to do. Plus many people are visually oriented learners, so they benefit with images every now and then. Of course, it's best not to overdo things and overload the site with too many images. A nice balance is needed.

5 0
2 years ago
The___is a waterproof fabric that is placed around your camera
Zina [86]
Can you help me with homework and the answer is a circle
5 0
3 years ago
When TCP/IP translates a network layer address into a data link layer address, it sends a special ____________ to all computers
Llana [10]

Answer:

Broadcast message

Explanation:

The network models like OSI and TCP/IP suites have standard layers and protocols that governs the communication of end devices in a network.

The TCP/IP suite model has four layers which are application, transport, internet and network access layers. The network access does the work of both the data-link and physical layer of the OSI model.

When the packet is encapsulated in a data-link header and trailer, and needs to be sent to another unknown host, a broadcast message is sent to all the computers in the network to retrieve the remote host address for a unicast transmission to take place.

3 0
3 years ago
Read 2 more answers
In 1940, the FCC reserved a set of frequencies in the lower range of the FM radio spectrum for _____ purposes as part of its reg
Monica [59]

Answer:

education purposes

Explanation:

Education institutes make some programs like School of the Air and College of the Air, forums, and discussion tables, in 1940 the FCC reserved a range of the FM radio spectrum for education purposes.

Although FM was unpopular when the FCC moved the FM bandwidth to a higher set of frequencies, and people and consumer stations had to buy new equipment.

5 0
3 years ago
A display that is thin flexible, light, and easy to read in all types of light is an
Nuetrik [128]

Answer; Electric Paper Display

Explanation:

<em>"PDs are extremely thin and only require power when a new image is requested. Instead of a traditional display that uses backlighting to illuminate pixels, an EPD is based on the scientific phenomena known as "electrophoresis," the movement of electrically charged molecules in an electric field."</em>

Above is the definition, as you can see it resembles your question greatly so this is most likely the answer you're looking for.

Good luck :D

8 0
3 years ago
Read 2 more answers
Other questions:
  • Safety interlock module operates by monitoring the voltage from the
    7·1 answer
  • When we insert a new node into a red-black tree, we set the color of the newly inserted node n to red. observe that if we had ch
    15·1 answer
  • Which does an icon on the desktop signify?
    12·1 answer
  • Lures, reels, rods, hooks, baits and nets are common equipment used in what food gathering method?
    15·2 answers
  • A band wants to know what their most popular CD is so that they can have more copies made to sell. Which statistical measurement
    11·2 answers
  • HELP PLEASE!!! I do online school, someone is in another state wanting to help me. No not do my work for me but view what I view
    6·1 answer
  • Where in the Formula tab on the ribbon would you find the Use in Formula function?
    11·2 answers
  • Which of the following is used to move to end of the row?​
    8·1 answer
  • Designing a video game takes tons of creativity. What inspires your personal creativity and ideas for video games? Explain and g
    15·1 answer
  • What is the following file format called? inv_nbr, inv_name, inv_cost 876521,battery,45.00
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!