**PLEASE PLEASE PLEASE HELP ME ... I AM SO CONFUSED**

Q1:

Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0.

__________________________________________________ ______________

Q2:

Assume the int variables i , lo , hi , and result have been declared and that lo and hi have been initialized.

Write a for loop that adds the integers between lo and hi (inclusive), and stores the result in result .

Your code should not change the values of lo and hi . Also, do not declare any additional variables -- use only i , lo , hi , and result .

__________________________________________________ ______________

Q3:

Given 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 whole 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 .

__________________________________________________ ______________

Q4:

Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

__________________________________________________ ______________

Q5:

Assume the int variables i and result , have been declared but not initialized. Write a for loop header -- i.e. something of the form

for (* . * . * . * )

for the following loop body:

result = result * i;

When the loop terminates, result should hold the product of the odd numbers between 10 and 20.

NOTE: just write the for loop header; do not write the loop body itself.