0% found this document useful (0 votes)
9 views

Intro To Pascal Programming

Uploaded by

Nathefa Layne
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Intro To Pascal Programming

Uploaded by

Nathefa Layne
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Intro to Pascal Programming

Pascal is a high-level language which is widely


used as a starting or as a teaching language.
However, nowadays Pascal is sometimes
preferred to other languages, and could be useful
to solve technical problems. It is not necessary to
learn any other easier language to start learning
Pascal, or any of that sort. It is a very easy
programming language and helps you to
understand the basics of the world of
programming. Also, it greatly helps you in order
to start learning the C programming language.
Key Points
• The same algorithms created in the previous lessons can
be implemented as a program.

• At the beginning of the course we learnt that a program is


set of instructions that tells the computer what to do.

• We have various application programs that we interact


with daily such as WhatsApp, FaceBook and Instagram.

• Today we will learn how to create programs in high level


language.
Programming Language
• This is a language used to write instructions
that can be translated into machine language
and then executed by a
computer.

• Just as how people across the world speak


different language and sit exams in different
language programs can be written in different
language.
Generation of Languages
Low Level Programming Languages
-First Generation Language (1GL)
▫ Machine Language

Second Generation Language(2GL)


▫ Assembly Language
Generation of Languages
High Level Programming Languages
-Third Generation Language(3GL)
▫ Pascal,Python,Java

-Fourth Generation Languages(4GL)


▫ Sql

-Fifth Generation Language(5GL)


▫ Lisp
Basic Pascal Syntax
To Display a statement

• WRITELN: is used to display a statement on a


screen
▫ For example WRITELN (‘Hello Students!’);
▫ For example WRITE(‘Enter the price’);

• To input a value type

• READLN(Name of Variable);
For Example:
• READLN(Price);
Basic Syntax cont’d
• Begin with the keyword PROGRAM
• Give the program a name example: PROGRAM
INVENTORY;
• Replace your as with colons (:)
• Use VAR instead of Variable or Declare
• Use CONST instead of Constants
• All statements end with a semi-colon (;)
• All Prompt Statements should have quotations
▫ For Example:
WRITELN( ‘Enter the quantity’)

• USE BEGIN instead of START


• USE END. Instead of STOP
• Provide a brief description of what the program is
doing
▫ For Example:
▫ WRITELN(‘This program will accept the price and
quantity and print the total price’);
Let’s Rewrite the Algorithm to Pascal
START
Declare price as REAL
Declare quantity as INTEGER
PRINT “Enter the quantity”
Read quantity
PRINT “Enter the price”
Read price
TotalPrice=price*quantity
PRINT “The total price is”, TotalPrice
STOP
Pascal
Program Inventory;

VAR
Totalprice, price: REAL;
quantity: INTEGER;

BEGIN
WRITELN(‘This program will accept the price and quantity and
find and print the total’);
WRITELN(‘Enter the price’);
READLN(price);
WRITELN(‘Enter the quantity’);
READLN (quantity);
Totalprice:=price*quantity;
WRITELN(‘The total price is’, Totalprice);
Readln();
END.
Activity
Write a Pascal program to find the area of a
rectangle .

You might also like