# loops

• 10-02-2005
derangedrobot
loops
I have just started learning c++ for like a mont on and off, but i have a problem well its more like y is this doing wat its doing... i though since you can make a program count from 0 to 10 or watever and i can make it count backwards from 10 then i should be able to make it count by 5's..

well this is the only way i could do this

Code:

```#include <iostream> using namespace std; int main() {     for( int x = 0; x < 11; x++ ) {             cout<<x * 5 <<endl;     }     cin.get(); }```

now im fine with that but y do i have to use 11 instead of 50. is it because that is tell the program how many times to loop it or wat??
• 10-02-2005
Enahs
Quote:

now im fine with that but y do i have to use 11 instead of 50. is it because that is tell the program how many times to loop it or wat??
You do not have to use 11, you can use any number you want.

I am not sure what you are asking?

To make it count by 5's instead of "x++" you could just do "x + 5"
"x++" is the same thing as "x + 1".
• 10-02-2005
derangedrobot
Quote:

To make it count by 5's instead of "x++" you could just do "x + 5"
see i tried using x + 5 instead of x++, but the program just ran 0 like a million times..
• 10-02-2005
ChaosEngine
Quote:

Originally Posted by derangedrobot
see i tried using x + 5 instead of x++, but the program just ran 0 like a million times..

try x += 5
x + 5 does nothing to x.
x += 5 is the same as x = x + 5
• 10-02-2005
derangedrobot
lol some how i knew it was going to be somthing as simple as that, ty that was going to bug me for ever.