Ask Question

Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do ... while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables other than n, k, and total. 0

+3
Answers (1)
  1. 4 May, 16:31
    0
    Following are the statement:-

    total = 0, k=0; / / variable declaration

    do

    {

    total = total+Math. pow (k, 3); / /perform the operation

    k+ +;

    }while (k<=n);

    Explanation:

    Following are the description of statement:-

    In this we declare a variable total that is initialized with the 0 value. The do while loop is executed at least one time either condition True or False. We Iterating the do while loop until k is less than equal to n. In each iteration we calculate sum of the cube of n whole number.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers