loops using "FOR"

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

loops using "FOR"

Post by Steve001 »

Evening all,

looking to make a counting loop , and wanting some advice please

i am familiar with the following example:

FOR N = 0 TO 10 STEP 1
PRINT N
NEXT N

which will print 1,2,3, etc

It has been so long since i have done any programming,
i am looking for an example

i believe it's

for . . .

end if

i'm a bit lost if somebody can point me in the right direction please


steve
Success always occurs in private and failure in full view.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: loops using "FOR"

Post by JohnCrow »

Hi Steve

Its a long time since I did any C programming, Id realy like to get back into it.
If I remember to leave a "FOR" loop the command is "RETURN"

This is a simple example from a C programming book ive got on the shelf

#include <stdio.h>
main()
{
int ctr; /* set variable ctr as integer */

for (ctr = 1; ctr<=10; ctr++) /*start ctr at 1 and increment through loop */

{ printf ("%d \n", ctr) ; } ? * Body Of Loop */

return;
}
Program will print 1 2 3 4 5 6 7 8 9 10 (in a vertical line)

Im sure the guys at Matrix will give you a better answer when they come in.

Hope this is a help
1 in 10 people understand binary, the other one doesn't !

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: loops using "FOR"

Post by Steve »

(I don't think a better answer is needed!)

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: loops using "FOR"

Post by Steve001 »

thanks for that , will have a go :D :D

steve
Success always occurs in private and failure in full view.

Post Reply