Several derivatives of Pascal exist which enhance the language, such as Object Pascal.
Why would I learn this language?
Pascal is considered to be one of a few languages which one can learn completely. The language is deliberately limited and (by default) there are few external libraries. In this sense, learning Pascal is a finite process.
Pascal has a simple syntax and easy to understand type system. Programs are generally fairly easy to read and write.
Pascal is a fairly well established language, but is also not very modern.
- Learn Pascal
- Beginner guide to programming using Pascal.
- Free Pascal
- Open Source Compiler for Pascal and Object Pascal.
Here is an example of the Fizz Buzz problem:
program FizzBuzz(output); var i : integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
Here is an example of the 100 doors problem:
program OneHundredDoors; var doors : Array[1..100] of Boolean; i, j : Integer; begin (* Initialize the array of doors to closed *) for i := 1 to 100 do doors[i] := false; (* Process the doors *) for i := 1 to 100 do begin j := i; while j <= 100 do begin doors[j] := not doors[j]; j := j + i end end; (* Print out the results *) for i := 1 to 100 do begin Write('Door #', i, ' is '); if doors[i] then WriteLn('open.') else WriteLn('closed.'); end; end.