Ask Question
16 June, 11:27

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.

+1
Answers (1)
  1. 16 June, 11:52
    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?
Find 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 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