Title here
Summary here
Pascal has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
program Values;
uses
SysUtils;
begin
// Strings, which can be concatenated with '+'
WriteLn('pascal' + 'lang');
// Integers and floats
WriteLn('1+1 = ', 1 + 1);
WriteLn('7.0/3.0 = ', 7.0 / 3.0 : 0 : 16);
// Booleans, with boolean operators as you'd expect
WriteLn(True and False);
WriteLn(True or False);
WriteLn(not True);
end.
To run the program, save it as values.pas
and use a Pascal compiler like Free Pascal:
$ fpc values.pas
$ ./values
pascallang
1+1 = 2
7.0/3.0 = 2.3333333333333335
FALSE
TRUE
FALSE
In this Pascal program:
WriteLn
instead of fmt.Println
to output to the console.+
operator, similar to many other languages.and
, or
, and not
instead of &&
, ||
, and !
.begin
and end.
to denote the main program block, rather than curly braces.: 0 : 16
in the float division line specifies the format of the output (0 digits before the decimal point, 16 after).Note that Pascal is case-insensitive, so TRUE
, True
, and true
are all valid and equivalent.