# Thread: Iterative help

1. Member
Join Date
Oct 2009
Posts
13
Rep Power
0

## Iterative help

Im writing a program that takes a number inputed and prints the first n positive numbers beginning at 0 by 10's, separated by spaces.

For example: n=4 prints 0, n=65 prints 0 10 20 30 40 50 60

Im not understanding how to write this using an iterative method. Any help please?

2. Moderator
Join Date
Apr 2009
Posts
13,132
Rep Power
23
Write out a description of what it is you would need to do to do this by hand, step by step...then use that to structure your code.

3. Member
Join Date
Oct 2009
Posts
13
Rep Power
0
i have tried that but i cant seem to understand what i would need to write in order for it to print out 10 20 30 40 50 60 if n=65

4. Moderator
Join Date
Apr 2009
Posts
13,132
Rep Power
23
You'll need a loop, probably.

Now think what the exit condition will be for that loop.

5. This is a fundamental skill for programmers. You know how to do it by hand, obviously, because you can describe what you need to do. Do it by hand, and stop to think before you write each number: how did I figure that out? How would I tell somebody else, who had no other knowledge, how to do that?

6. Senior Member
Join Date
Oct 2010
Posts
393
Rep Power
7
Assuming you know how to write an iterative statement, they don't have to just increment by one (e.g. n++, ++n) but can be incremented by any amount (e.g. n+=2, n+=3, n+=4 , increments n by 2, 3, 4 respectively).

I can't give away too much too soon but I hope this helps.
If you're still struggling then post back.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•