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

Respuesta :

Answer:

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.