2011 5th form online thingie #1

The following Pascal program was given as a demonstration of FOR loops:

program looptest;

var
	counter: integer;

begin
	for counter := 1 to 100 do
		writeln(counter);
end.

A for loop follows this format:

For ← <start value> TO/DOWNTO <end value> Do
Begin
	...
	...
End

A FOR loop is a definite loop (we know how many times it must loop).

A FOR loop loops to or down to a given value.

Pascal concepts:

:= is used for assignment (the same as ← in pseudocode)
The final END statement has a . after it instead of the usual ;

These exercises were given, and are due Tuesday March 15 2011:
Chapter 2 Exercise 6a, 6b, 6c, and 6e

Advertisement

About Nathanael

I'm an aspiring indie game developer who's working on an awesome AI system and The Ultimate Ambitious Game (actual name) long-term, while working on a simple game each month to avert boredom and/or make side-money.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s