*/
Stuck? Need help? Ask questions on our forums.
*/

View \LOOPDEMO.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 4 - Program 1 *)
program Demonstrate_Loops;

var Count  : integer;
    Start  : integer;
    Ending : integer;
    Total  : integer;
    Alphabet : char;

begin
   Start := 1;
   Ending := 7;
   for Count := Start to Ending do      (* Example 1 *)
      Writeln('This is a count loop and we are in pass',Count:4);

   Total := 0;
   for Count := 1 to 10 do begin        (* Example 2 *)
      Total := Total + 12;
      Write('Count =',Count:3,'  Total =',Total:5);
      Writeln;
   end;

   Writeln;
   Write('The alphabet is ');
   for Alphabet := 'A' to 'Z' do         (* Example 3 *)
      Write(Alphabet);
   Writeln;

   for Count := 7 downto 2 do            (* Example 4 *)
      Writeln('Decrementing loop ',Count:3);

end.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.