Free Pascal Program Tutorial 3 - Variables and Data Types - Lazarus

Опубликовано: 12 Май 2012
на канале: SchoolFreeware
129,847
871

http://www.schoolfreeware.com

The Free Pascal Compiler and Lazarus can be downloaded at no cost at www.freepascal.org. Free Pascal and Lazarus are a Turbo Pascal / Delphi clone that can make programs for Windows, Macintosh (Mac OS X), and Linux.

This tutorial will cover data types. The data types that are most common are the integer, real (floating point), string, char, and boolean. There are several other data types that are built into Free Pascal. The list is found in the documentation on Free Pascal's Website www.freepascal.org.

The common data types that should be known are:

Integer  - It is a whole number. Its range varies by system. For example in Windows XP the integer's range is -2147483648 to 2147483647.

Real  - Real is a floating point number. Its range varies by system. For example in Windows XP, real's range 5.0E - 324 to 1.7E 308.

String - String is text.

Char - Char is a single text character by the computer. For example: a, B, &, @, l, and 4.

Boolean - A boolean variable is either TRUE or FALSE


To create a variable, place the word var between the uses section and begin (program section). The syntax for variable include:

name_of_variable:data_type;

Example:

var
  name:string;
  num1:integer;
  num2:integer;
  total:real;