|
Would you like to add up all the even integers from zero to one thousand? A good answer might be:Probably not. Even with a hand calculator this would be tedious. | |
Adding Up Even and Odd IntegersThere are simple formulas for the sum of even integers from 0 to N, for the sum of odd integers from 0 to N, and for the sum of all integers from 0 to N (look in your calculus book if you are interested.) But pretend that you don' know that. Let us write a program that calculates these three things. The user will enter the limit, N, and the program will count up from zero to N, adding each count to the appropriate sums. Here is a skeleton for the program that does this:
| |
QUESTION 2:First, get the counting loop correct. Complete the three blanks (corresponding to the three aspects of a loop you must coordinate) so that the loop counts from zero to (and including) the limit. Click Here after you have answered the question |