Loading…

Online Pascal Compiler and Playground

Browser-based compiler and playground for Pascal, Progsity IDE.

About Pascal

Pascal was designed for teaching programming, and it shows: a program reads top to bottom, every variable is declared before use, and begin and end mark each block in words. Many school curricula and olympiad archives still use it, and Delphi keeps it alive in desktop software.

The playground compiles with Free Pascal in Delphi mode and runs the native binary in a sandbox. In this mode Integer is 32 bits, Int64 is there when you need more, and string is a long string with no 255 character limit. The run-time library units such as SysUtils, Math and StrUtils are available.

Compilation takes a fraction of a second, so it is practical to change one line and run again while you learn.

How to use

  1. Start with program Name; then the var section, then begin ... end. with the final full stop.
  2. Type the input in the stdin panel and read it with Read or ReadLn.
  3. Press Run. A compiler error shows the line and column in brackets, for example (7,12).

FAQ

Which Pascal compiler is this?›

Free Pascal 3.2, in Delphi mode with optimisation on. Programs written for Turbo Pascal or Delphi's console mostly compile unchanged, apart from units such as crt.

How big is Integer?›

32 bits here, up to about two billion. Use Int64 for sums and products that can pass that.

Can I use the crt unit or graphics?›

Leave them out. They expect a real terminal, and a program here only reads standard input and writes standard output: there is no screen for ClrScr and no key for ReadKey.

Are C-style operators like += allowed?›

Yes. The compiler is set to accept +=, -=, *= and /= alongside the usual := assignment.

Can I save a program?›

Yes, after signing in. Running needs no account.

Code examples

Tap “Try this” to load sample code into the editor above.

  • A for loop

    program Squares;
    var
      i: Integer;
    begin
      for i := 1 to 5 do
        WriteLn(i, ' squared is ', i * i);
    end.
  • Read two numbers

    program Sum;
    var
      a, b: Int64;
    begin
      ReadLn(a, b);
      WriteLn(a + b);
    end.
  • Largest value in an array

    program Largest;
    const
      Nums: array[1..6] of Integer = (3, 1, 4, 1, 5, 9);
    var
      i, best: Integer;
    begin
      best := Nums[1];
      for i := 2 to 6 do
        if Nums[i] > best then
          best := Nums[i];
      WriteLn('Largest: ', best);
    end.
  • A recursive function

    program Factorial;
    
    function Fact(n: Integer): Int64;
    begin
      if n <= 1 then
        Fact := 1
      else
        Fact := n * Fact(n - 1);
    end;
    
    begin
      WriteLn(Fact(20));
    end.