Sample Code
- Pascal is not case sensitive.
- Historically, Pascal comments are enclosed
{ within pairs of braces }
, or(* left parenthesis/asterisk and asterisk/right parenthesis pairs *)
, and these can span any number of lines. Later versions of Borland Pascal also supported C++-style comments// preceded by two forward slashes
, which finish at the end of the line. - The syntax for the statement
case
is more flexible than standard Pascal. - Sets may only have up to 256 (28) members.
- Standard, fixed-length Pascal strings are supported, but there is also a more flexible
String
type.
This is the classic Hello world program in Turbo Pascal:
program HelloWorld; begin WriteLn('Hello World') end.This asks for a name and writes it back to the screen a hundred times:
program WriteName; var i : Integer; {variable to be used for looping} Name : String; {declares the variable Name as a string} begin Write('Please tell me your name: '); ReadLn(Name); {ReadLn returns the string entered by the user} for i := 1 to 100 do begin WriteLn('Hello ', Name) end end.Read more about this topic: Turbo Pascal
Famous quotes containing the words sample and/or code:
“All that a city will ever allow you is an angle on itan oblique, indirect sample of what it contains, or what passes through it; a point of view.”
—Peter Conrad (b. 1948)
“Wise Draco comes, deep in the midnight roll
Of black artillery; he comes, though late;
In code corroborating Calvins creed
And cynic tyrannies of honest kings;
He comes, nor parlies; and the Town, redeemed,
Gives thanks devout; nor, being thankful, heeds
The grimy slur on the Republics faith implied,
Which holds that Man is naturally good,
Andmoreis Natures Roman, never to be
scourged.”
—Herman Melville (18191891)