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]
2 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]2 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
4. Write technical term for the following statements
IRISSAK [1]

A=Application software

C=Microcomputer

D=hybrid computers

E=digital computer

F=Handheld computer

G=Dextop computer

Sorry,i couldn't help you in B.

5 0
3 years ago
Read 2 more answers
How to cite a website, like asha.org?
inn [45]
Using the APA style or the<span> American Psychological Association style of referencing or citing sources, the structure for website reference is as follows:
</span>Last, F. M. (Year, Month Date Published). Article title<span>. Retrieved from URL. Hence, for the problem:
</span>Last, F. M. (Year, Month Date Published). Article title<span>. Retrieved from http://www.asha.org</span>
8 0
3 years ago
Brook is designing a database that customers can use to find their ideal vacation spot. If they only want to see beach vacations
Aleksandr [31]

Answer:

filter the data

Explanation:

its like when you filter a search on y o u t u b e and say u search among us u can filter and say live vids or channel's

7 0
2 years ago
Read 2 more answers
The true or false questions.
DIA [1.3K]

Answer:

true

Explanation:

The command:

find -empty -type f -exec rm { } \;

carries out the following steps.

1) Finds all the empty files in the current directory and its subdirectories.

2) For each of the identified files, it executes the command specified as the parameter to exec option,namely, rm <filename>.

So effectively it removes all empty files in the directory tree starting at the current directory.  

7 0
3 years ago
While the Internet can be a great resource, the information is not always reliable, as anyone can post information. Select one:
Olin [163]

Answer: True

Explanation: Because anyone can post something and it can be non reliable

7 0
2 years ago
Other questions:
  • Write a sequence of statements that create a file named "greeting" and write a single line consisting of "Hello, World!" to that
    5·1 answer
  • We can see spreadsheet results graphically by creating:
    15·1 answer
  • Amazon Web Services (AWS): Group of answer choices a) forms a majority percentage of Amazon's overall revenue. b) was introduced
    15·1 answer
  • What is after Windows 8.1
    11·2 answers
  • I have tried installing "windows media player" on my computer but at a point, something disrupts its instalment or I am asked to
    7·1 answer
  • Try writing pseudo code that describes how your device uses input data to perform the action that you want.
    9·1 answer
  • The 8-bit ____ field is used by source network hosts and forwarding routers to distinguished classes or priorities in ipv6 packe
    11·1 answer
  • That's my email address​
    14·1 answer
  • If the old and new systems are operated side by side until the new system has proven itself, this type of system conversion plan
    11·1 answer
  • Juhfvehrfwhedfhwkefhkujhiuyuiyuiyiyh
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!