Ask Question

ven int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 positive integers 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. 17 May, 21:56
    0
    Following are statement is given below

    int k=1, total=0; / / variable declaration

    while (k<50) / / iterating the while loop

    {

    total=total+k*k; / / calculating the square

    k=k+1; / / increments the value of k by 1

    }

    Explanation:

    Following are the description of Statement.

    Declared a variable "total" and "k" of the "integer " type initialized the total to 0 and "k" to 1. Iterating the while loop for less then 50. In this loop, we calculating the sum of square of first 50 number in the "total" variable. After that increment the value of "k" variable by 1 to execute the loop less then 50.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “ven int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 positive ...” 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