English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

WHAT DOES THIS ACTUALLY MEAN?

2006-09-21 12:07:47 · 2 answers · asked by ? 1 in Computers & Internet Programming & Design

2 answers

"lo" and "hi" are variables. They're looking for you to write a for loop that calculates "result" (another variable). Imagine that lo = 15 and hi = 20 if that helps. In that example, once you're done you should have result = 105 (that's what you get from 15 + 16 + 17 + 18 + 19 + 20). Inclusive means that you should include the ends (in the example, 15 and 20) in your calculation.

2006-09-22 13:03:34 · answer #1 · answered by csmonkey 2 · 1 0

You want a loop that starts with an index set equal to the value of the integer variable "lo" and increments the index by 1, adding the current value of the index to the prior subtotal, until it reaches the value "hi", then store the final total in a variable called "result".

2006-09-21 19:16:11 · answer #2 · answered by Fix My PC Mike 5 · 2 0

fedest.com, questions and answers