Ask Question
10 April, 18:47

Use two variables k and total to write a for loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus, your code should put 1*1 2*2 3*3 ... 49*49 50*50 into total. use no variables other than k and total.

+2
Answers (1)
  1. 10 April, 21:06
    0
    I think the question means to "accumulate" or "sum" the individual squares in total. "Store" in computer terms usually means overwriting what's already in total.

    With the sens of "summing" or "accumulating", this is one way how it can be coded:

    int total=0;

    for k=1 to 50 {

    total+=k^2;

    };

    print (total);
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Use two variables k and total to write a for loop to compute the sum of the squares of the first 50 counting numbers, and store this value ...” in 📙 Mathematics 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