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
Briefly list four of the basic I/O interface standard? ​
tiny-mole [99]

Four of the basic I/O interface standard are PCI, SCSI, USB and ISA.

<h3>Standard I/O Interface</h3>

Input-Output Interface is used as an method which helps in transferring of information between the internal storage devices. A number of standards have been developed for I/O Interface.

There widely used bus standards are:

  • PCI (Peripheral Component Interconnect)
  • SCSI (Small Computer System Interface), and
  • USB (Universal Serial Bus).
  • ISA (Industry Standard Architecture)

Find out more on Standard I/O Interface at: brainly.com/question/24347579

4 0
2 years ago
What is a key function of a scrum master plato answer plz
sdas [7]
The scrum master is the team role responsible for ensuring the team lives agile values and principles and follows the processes and practices that the team agreed they would use.
6 0
3 years ago
Is the Internet dangerous?
VARVARA [1.3K]

Many people would answer this in many different ways. In my personal opinion, it's a yes. It's a yes because it makes it easier for people to track you down (finding your iep) and it's easy for someone to take your identity. It's also dangerous for children and teens (even young adults) because there are many people wanting them, and wanting to meet them in public and things like that. I hope I answered your question! (:

8 0
2 years ago
Read 2 more answers
Write Python code to save the data to a MongoDB collection:Import json module to parse JSON dataImport MongoClient from pymongo
Zigmanuir [339]

Answer:

Explanation:

The objective of this task is to compute a program that involves the usage of Python code to save the data to MongoDB and to query  the database.

Due to the error that occur which makes me to be unable to submit this answer, I've created a word document instead and the attached file can be found below.

Thanks!

Download docx
8 0
2 years ago
A major weakness of a lot of file processing systems is that ____.
Gnesinka [82]

They are several weaknesses or disadvantages of file processing systems but the major weakness is data redundancy and inconsistency. By data redundancy, I mean duplication of data. There are no better methods to validate insertion of duplicate data in file systems. Data redundancy can also increase the chance for errors.






7 0
3 years ago
Other questions:
  • An attribute whose value uniquely identifies an object is called a(n) _______.​
    15·1 answer
  • Which of the following is NOT a common GUI component? O a. Label b. Button c. Key press d. Text box
    12·2 answers
  • Which of the following is a template definition?
    5·1 answer
  • 1. What are the biggest risks when using the public Internet as a Wide Area Network (WAN) or transport for remote access to your
    6·1 answer
  • What lie does E.D. tell to keep the musical from being canceled? There is a television crew coming to do a story on it. Jake wil
    6·1 answer
  • 1. In the.js file, write the JavaScript code for this application. Within the click event handlers for the elements in the sideb
    14·1 answer
  • Nonprogrammed decision
    7·1 answer
  • What is digital marketing?
    5·1 answer
  • A slide titled Alexander Graham Bell. There are 6 bulleted entries on the slide, and there is a lot of text on the slide. There
    11·2 answers
  • What is one of the advantages of using an algorithm to solve a puzzle like Kriss-Kross or Sudoku?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!