Hello World in Pascal

Published on 12 May 2019 (Updated: 12 May 2019)

Hello World in Pascal

In this article, we’re tackling Hello World in Pascal.

How to Implement the Solution

There’s no time to waste! Let’s dig right into Hello World in Pascal:

program HelloWorld(output);
  writeln('Hello, World!');

As usual, we’ll tackle this implementation line by line. Up first, we have the program line which declares the name of the program and a list of file descriptors.

Up next, we have our main block which is denoted by the begin and end keywords. Within this block, we have the print statement. Of course, the function we use in Pascal is called writeln.

Finally, we have a period, also known as a full stop. This indicates the end of the program.

As an added tidbit, semicolons mark the ends of statements, but they are optional on the last statement in a block. In other words, we could have removed the semicolon after the writeln command.

How to Run the Solution

If we want to try any of the Pascal code snippets from this article, we can use an online Pascal compiler. We just need to drop the snippets into the online editor and hit run.

Of course, we can always download and install Pascal locally. While we’re downloading stuff, we should probably get a copy of the solution.

Assuming Pascal is now in our path, we can navigate to our folder containing the solution and run the following commands from the terminal:

fpc hello-world.p
hello-world.exe  # Windows
./hello-world  # Unix/Linux/Mac

Since Pascal is a compiled language, we first need to compile our script. After compilation, we’ll have an executable we can run. When we run it, the “Hello, World!” string should print to the console1.


  1. J. Grifski, “Hello World in Pascal,” The Renegade Coder, 14-Apr-2018. [Online]. Available: https://therenegadecoder.com/code/hello-world-in-pascal/. [Accessed: 08-May-2019].