Question: I would like to understand the basics of how to write and execute a pascal program on Linux OS. Can you explain it with a simple example?
Answer: In this article, let us review very quickly how to write a basic Hello World pascal program and execute *.p or *.pas program on Linux or Unix OS.
1. Write a Hello World Pascal Program
Create the helloworld.p program using a Vim editor as shown below.
$ vim HelloWorld.p
Program HelloWorld(output);
begin
writeln('Hello, world!');
end.
2. Make sure pascal compiler is installed on your system
Make sure pascal compiler is installed on your system as shown below.
$ whereis pc pc: /usr/bin/pc /usr/share/man/man1/pc.1.gz $ which pc /usr/bin/pc
Installing pascal compiler
If you don’t have pascal compiler, install it as shown below.
$ sudo apt-get install fp-compiler
3. Compile the pascal program.
Compile the HelloWorld.p which will create the HelloWorld executable.
$ pc HelloWorld.p Free Pascal Compiler version 2.2.2-8 [2009/01/08] for i386 Copyright (c) 1993-2008 by Florian Klaempfl Target OS: Linux for i386 Compiling HelloWorld.p Linking HelloWorld 4 lines compiled, 0.1 sec $ ls HelloWorld* HelloWorld.o HelloWorld.p
4. Execute the pascal program.
Execute by mentioning the program name.
$ ./HelloWorld Hello, world!
Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.Get the Linux Sysadmin Course Now!
If you enjoyed this article, you might also like..
|
|
|
|






My name is Ramesh Natarajan. I will be posting instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to write articles that will either teach you or help you resolve a problem. Read more about
{ 2 comments… read them below or add one }
Please show me how to write a progam in Pascal that calculates the average mark of a student given 5 exam marks and output the average.
Write a Pascal program to assign grades to scores of 100 students. The grading system is given as 70-100= A 60-69= B 50-59= C 45-49= D 40-44= E 0-39= F