Given an int variable n that has been initialzied 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 numbersx, and store this value in total. Use no variables other than n, k, and total.
LANGUAGE: Visual Basic
CHALLENGE:
Given an int variable n that has been initialzied 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 numbersx, and store this value in total.
Use no variables other than n, k, and total.
SOLUTION:
total = 0 For k = 0 to n total += k*k*k Next