Pascal

programming language

Pascal is a programming language. It was created in 1970 by Niklaus Wirth, to help people learn how to make computer programs.

DevelopmentEdit

Now, 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.

DescriptionEdit

Every 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 samplesEdit

This code prints Hello world! at console window:

1 program helloWorld(output);
2 begin
3 	writeLn('Hello world!');
4 	{ which is short for: writeLn(output, 'Hello world!); }
5 end.

This code calculate factorial of a positive integer, using recursion.

 1 program factorialDemo(input, output);
 2 
 3 function factorial(n: integer): integer;
 4 begin
 5 	if n < 2 then
 6 	begin
 7 		{ the result of a function is stored in a variable }
 8 		{ that has the same name as the function: }
 9 		factorial := 1;
10 	end
11 	else
12 	begin
13 		factorial := n * factorial(n - 1);
14 	end
15 end;
16 
17 var
18 	n: integer;
19 begin
20 	write('Enter number: ');
21 	readLn(n);
22 	writeLn(factorial(n));
23 end.

Pascal variantsEdit