Start New Discussion within our Software Development Community

For Statement examples,see it...

(*For those who now get on the train,'cause there are beginers always..*)

Program ForLoopExample;
Uses Crt;
Var i:Byte;

(*
Syntax:FOR STATEMENT

FOR MIN TO MAX DO ISTRUCTION1;

and can be down to step
FOR MAX DOWNTO MIN DO ISTRUCTION1;

or when there are more than one instruction
can be use a Begin..end; statement.See:

For min To max Do
    Begin
         Instruction1
         Instruction2
         Instruction3
         ...
         InstructionN
    End;            <--NOTE THAT HERE THERE ISN'T POINT

The 'Continue & Break' statements:
Continue:continues the looping
Break:stop looping
see:

Var i:Byte;     {0..255}
    Ch:Char;    {from ascii}


For i:= 1 To 100 Do
    Begin
         If (i Mod 5 = 0) Then {if 'i' can be divide with 5 without }
            Begin               {remainder then.. }
                 WriteLn(i);    {write i's value,like 5}
                 Write('Continue? Y or N : ');  {there is a question}
                 ReadLn(Ch);      {here we catch the answer}
                 Case (Ch) Of     {and analize it}
                      'Y':Continue;  {if press Y or y then looping}
                      'y':Continue;
                      'N':Break; {if press N or n then stop looping}
                      'n':Break;
                 End;{case}

            End;
    End;
ReadLn;
*)

Begin
     For i:=1 To 10 Do
         Begin
              {these lines will be writen for 10}
              WriteLn(i:3,'. Hello From The Pascal');
         End;
     ReadKey;
End.
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.