Ask Question
26 February, 21:05

Given a variable n refers to a positive int value, use two additional variables, k and total to write a for loop to compute the sum of the cubes of the first n counting numbers, and store this value in total. thus your code should put 1*1*1 + 2*2*2 + 3*3*3 + ... + n*n*n into total. use no variables other than n, k, and total.

+1
Answers (1)
  1. 26 February, 21:28
    0
    You could do it like this (example for n=5).

    int n = 5;

    int total = 0;

    for (int k = 1; k < = n; k++) total + = k*k*k;
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given a variable n refers to a positive int value, use two additional variables, k and total to write a for loop to compute the sum of the ...” 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