i need help with the logic
Author |
Message |
steven.yuan3
|
Posted: Wed Jan 27, 2010 6:06 pm Post subject: i need help with the logic |
|
|
this is the question i am working on, im not sure how to put it into a for or while loop. any ideas?
Description: |
|
Filesize: |
74.51 KB |
Viewed: |
128 Time(s) |

|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
jbking
|
Posted: Wed Jan 27, 2010 6:17 pm Post subject: Re: i need help with the logic |
|
|
Let's go over a few different points here. Consider a for loop for a moment. What do you want to be set at the start of the loop? What exit criteria should there be? What kind of increment should happen in the loop?
For example, to go from 1 to 10 in steps of 2, here is the C++:
code: |
for (int i = 1; i < 10 ; i=i+2)
{
// do something here with the i.
} |
If you still need help, please specify where your difficulty is as I don't think the question is that hard, myself.
|
|
|
|
|
 |
wtd
|
Posted: Wed Jan 27, 2010 11:12 pm Post subject: RE:i need help with the logic |
|
|
What's the same every time?
4
What changes?
The denominator and the use of addition or subtraction.
How does the denominator change?
It always increments by 2.
How does the arithmetic operator change?
It adds every other time around.
|
|
|
|
|
 |
HRI
|
Posted: Wed May 05, 2010 7:46 pm Post subject: Re: i need help with the logic |
|
|
For the adding and subtracting part, -1 can be a very useful number if used in the right way.
|
|
|
|
|
 |
|
|