Pascal
Pascal is a programming language. It was created in 1970 by Niklaus Wirth, to help people learn how to make computer programs.
Development
changeNow, there are many different dialects of the language, some of which support object-oriented programming. In 1990 the “Pascal” and “Extended Pascal” standards were registered with the International Organization for Standardization.
Description
changeEvery variable has to be declared before it is used. Pascal is a strongly typed programming language: Every variable has a data type. You are only allowed to assign values to the variable that are valid for the data type. This ensures that the programmer does not make unintentional mistakes.
Pascal is a imperative language.
The language distinguishes between procedures and functions.
A function
returns a value, a procedure
does not.
As such, a function
call appears in an expression, whereas a procedure
invocation is a statement.
Code samples
changeThis code prints Hello world!
at console window:
program helloWorld(output);
begin
writeLn('Hello world!');
{ which is short for: writeLn(output, 'Hello world!); }
end.
This code calculate factorial of a positive integer, using recursion.
program factorialDemo(input, output);
function factorial(n: integer): integer;
begin
if n < 2 then
begin
{ the result of a function is stored in a variable }
{ that has the same name as the function: }
factorial := 1;
end
else
begin
factorial := n * factorial(n - 1);
end
end;
var
n: integer;
begin
write('Enter number: ');
readLn(n);
writeLn(factorial(n));
end.
Pascal variants
change- GNU Pascal
- Free Pascal
- Delphi – Modern IDE for creating GUI programs for Microsoft Windows. There is an open source clone of it for Windows, Mac OS X and FreeBSD, named Lazarus.
- Turbo Pascal