Ask Question
12 September, 21:22

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.

+4
Answers (1)
  1. 12 September, 22:09
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers