# Arithmetic operation within FOR loop

206

Hi Everyone! Just seeking very quick help with a piece of code that i suspect is the source of errors in my program. Is it OK to use an arithmetic operation within "for" loop as a condition???

Foe example:

for(int i=k; i<k+21; i++)

{

statements.

}

Any help will be highly appreciated. Thanks.

17943

Why do you think it wouldn't be?
31841
soubra2003
Kenneth Njuguna:

Hi Everyone! Just seeking very quick help with a piece of code that i suspect is the source of errors in my program. Is it OK to use an arithmetic operation within "for" loop as a condition???

Foe example:

for(int i=k; i<k+21; i++)

{

statements.

}

Any help will be highly appreciated. Thanks.

Are you looking for the statement above a a quick example or you have a full code?
If you have the full code then the K should be predefined some where in the code
19

Kenneth Njuguna:

Hi Everyone! Just seeking very quick help with a piece of code that i suspect is the source of errors in my program. Is it OK to use an arithmetic operation within "for" loop as a condition???

Foe example:

for(int i=k; i<k+21; i++)

{

statements.

}

Any help will be highly appreciated. Thanks.

If there are errors, I assume, it's a problem in the logic of your statements. ;)

9536

Kenneth Njuguna:

Hi Everyone! Just seeking very quick help with a piece of code that i suspect is the source of errors in my program. Is it OK to use an arithmetic operation within "for" loop as a condition???

Foe example:

for(int i=k; i<k+21; i++)

{

statements.

}

Any help will be highly appreciated. Thanks.

Not a problem I've seen functions be used before.

`for(int i=k; i<OrdersTotal(); i++)`

And if you can use a function a little bit of arithmetic would be child's play.

206

John Davis:

Not a problem I've seen functions be used before.

And if you can use a function a little bit of arithmetic would be child's play.

Thanks everyone for the input. Indeed the errors are within the statements block.

206

Without a doubt one of the most helpful online communities and much appreciated for/to everyone!!!