Basic Pascal Tutorial/Hello, World

From Free Pascal wiki
Revision as of 20:57, 25 November 2007 by Kees (talk | contribs) (New page: Hello, World (author: Tao Yue, state: unchanged) In the short history of computer programming, one enduring tradition is that the first program in a new language is a "Hello, world" to th...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Hello, World (author: Tao Yue, state: unchanged)

In the short history of computer programming, one enduring tradition is that the first program in a new language is a "Hello, world" to the screen. So let's do that. Copy and paste the program below into your IDE or text editor, then compile and run it.

If you have no idea how to do this, return to the Table of Contents. Earlier lessons explain what a compiler is, give links to downloadable compilers, and walk you through the installation of an open-source Pascal compiler on Windows.

   1: program Hello;
   2:   begin (* Main *)
   3:   writeln ('Hello, world.')
   4: end. (* Main *)

The output on your screen should look like:

Hello, world.

If you're running the program in an IDE, you may see the program run in a flash, then return to the IDE before you can see what happened. See the bottom of the previous lesson for the reason why. One suggested solution, adding a readln to wait for you to press Enter before ending the program, would alter the "Hello, world" program to become:

   1: program Hello;
   2: begin (* Main *)
   3:   writeln ('Hello, world.');
   4:   readln
   5: end. (* Main *)
previous contents next