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
caseis 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
Stringtype.
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:
“The present war having so long cut off all communication with Great-Britain, we are not able to make a fair estimate of the state of science in that country. The spirit in which she wages war is the only sample before our eyes, and that does not seem the legitimate offspring either of science or of civilization.”
—Thomas Jefferson (17431826)
“Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.”
—Alice Foote MacDougall (18671945)