Ask Question
13 July, 05:00

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. 13 July, 08:15
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers