04:10:33 27/01/2022

The compiler became cross-platform — it allowed compiling programs for DOS và for Windows. Another major feature is the possibility of creating DLLs.

Turbo Pascal 7.0

## Examples:

### Factorial - Pascal (44):

This example uses recursive factorial definition.

Note that this example works in all given implementations of Pascal, but it produces slightly different results. In gpc everything works perfectly. Turbo Pascal and không tính phí Pascal have arithmetic overflow for factorial of numbers greater than 12, but free Pascal reports an error:

13! = Runtime error 215 at \$004013C7\$004013C7\$00401449\$004063E0

while Turbo Pascal doesn’t detect the error and simply prints wrong values:

13! = 193205350414! = 127894528015! = 200431001616! = 2004189184

This example doesn’t work in Turbo Pascal 3.0 và earlier due to absence of longint data type in these versions.

In GNU Pascal this program works without any problems.

program factorial;function fact(n: integer): longint;begin if (n = 0) then fact := 1 else fact := n * fact(n - 1);end;var n: integer;begin for n := 0 to 16 vì chưng writeln(n, '! = ', fact(n));end.

### Fibonacci numbers - Pascal (58):

This example uses recursive definition of Fibonacci numbers.

program fibonacci;function fib(n:integer): integer;begin if (n 2) then fib := 1 else fib := fib(n-1) + fib(n-2);end;var i:integer;begin for i := 1 to 16 do write(fib(i), ', '); writeln('...');end.

### Factorial - Pascal (96):

This example is exactly the same as main recursive example for Pascal implementations, except for that it uses real data type khổng lồ store factorial values. Command writeln(f:-1:0) outputs the floating point number f with 0 digits after decimal point and left-justifies it.

program factorial;function fact(n: integer): real;begin if (n = 0) then fact := 1 else fact := n * fact(n - 1);end;var n: integer;begin for n := 0 khổng lồ 16 vày writeln(n, '! = ', fact(n):-1:0);end.

### Hello, World! - Pascal (57):

program helloworld;begin writeln('Hello, World!');end.

bepgasvuson.vn alpha
Top 10 users:
All text is available under the terms of the GNU không tính phí Documentation License (local GFDL copy).Example programs sources additionally available under the terms of the BSD-style license.Privacy Policy

• x