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
What machine learning technique helps in answering the question
Zina [86]
I don’t know I need points :))))
4 0
3 years ago
Knowledge and experience help you
Zarrin [17]

Answer:

yes it can it shows u what you did wrong or what you did right

Explanation:

brainlet me please

8 0
3 years ago
Identify the correctly constructed ALTER TABLE statement to add a UNIQUE constraint to the column customer_number with the const
SVEN [57.7K]

ALTER TABLE customer ADD CONSTRAINT customer_number_unique UNIQUE (customer_number);

5 0
2 years ago
Rainforests are not generally considered a source of _______. d.<br> none of the above
Alexus [3.1K]
Rainforests are generally considered a source of D. none of the above because you can get food, medicine and spices from rainforests. The plants in the rainforests have many medicinal properties.
5 0
4 years ago
DRU is a small brokerage house that enables its clients to buy and sell
Rudik [331]

The complete question rather reads;

DRU is a small brokerage house that enables its clients to buy and sell

stocks over the Internet, as well as place traditional orders by phone or Fax. DRU has just decided to install a new e-mail package. One vendor offering an SMTP-based two-tier client-server architecture. The second vendor is offering a Web-based e-mail architecture. DRU doesn't understand either one but thanks the Web-based one should be better because, in their words, "the Web is the future".

<u>(a) Briefly explain to DRU management, in layperson's terms, the difference between the two.</u>

<u>(b) Outline the pros and cons of the two alternatives and </u>

<u>(c) Recommend to DRU about which is better</u>

<u>Explanation:</u>

a) SMTP stands for Simple Mail Transfer Protocol. Thus, put simply an SMTP-based two-tier client-server architecture is a package that involves using a client-server provider like Outlook. This implies that Outlook provides the client with his own unique PO Box (server) so to speak.

While the Web-based e-mail architecture enables the DRU access to online mail platforms like G-mail with little server customisation features.

b. The Web-based e-mail architecture is good for personal email activities because of its ease of operation, however, it does not provide top security and customisation features. While an SMTP-based two-tier client-server architecture allows for unique server customisation with added security features as well be suitable for larger organisational work. Although a disadvantage is that it may cost more and quite a complex process to learn.

c) Since DRU is a growing firm the SMTP-based two-tier client-server architecture would be recommended as this would provide it will efficient customer service delivery.

6 0
3 years ago
Other questions:
  • __________ is a website that offers a variety of Internet services from a single, convenient location.
    13·1 answer
  • "if x and y are odd integers, then x + y is even"
    15·1 answer
  • Which of these shortcuts becomes available only when text is highlighted?
    10·1 answer
  • Phoebe has to give a permission about recycling. Where should she look while presenting?
    11·1 answer
  • Match the tool to the task it helps to accomplish. Thesaurus allows the user to find the synonyms and antonyms of a word Smart L
    8·1 answer
  • An objective function in linearprogramming is a(n):
    11·1 answer
  • As you are talking to your colleague over the phone, the sound of an airplane flying low drowns out part of your conversation. I
    11·1 answer
  • What are different ways that celebrities try to connect with fans using the Internet and social media?
    5·1 answer
  • Which of the expressions is false? when a = 10 and b = 4
    8·1 answer
  • Who are all the fnaf characters?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!