Pascal Programming Session 1

Post on 21-May-2015

3.647 views 3 download

Tags:

Transcript of Pascal Programming Session 1

Pascal Programming

http://ashesh.ramjeeawon.infoManagement Student/ Freelance DeveloperUniversity of Mauritius

Module Pre-Requisites:

Problem-Solving Techniques

Session 1: Pascal Fundamentals

Pascal Programming

Today’s Session

1. Intro to Pascal

2. History of Pascal

3. Getting the tools (IDE/Compiler)

4. The basic structure of a Pascal Program

5. Identifiers

6. Data Types

7. Input and Output

Pascal Programming

Intro to Pascal

Pascal is a general-purpose, high-level programming language

Derived from Algol-60

Specifically designed to encourage the use of Structured Programming

Pascal Programming

Intro to Pascal

Pascal was named in honour of Blaise Pascal (1623 – 1662)

Brilliant French Scientist and Mathematician Invented the word’s first calculating machine (Pascaline)

Pascal Programming

History of Pascal

Developed in the early 1970s by Niklaus Wirth at

The Technical University in Zurich, Switzerland

Pascal Programming

History of Pascal

In 1983, Borland International began marketing of an inexpensive compiler called Turbo Pascal.

Pascal Programming

Getting the tools

Pascal Programming

Getting the tools

Turbo Pascal for WindowsGetting hands dirty with the IDEInstalling the Turbo PascalCode writing aidsCompiling DebuggingSaving source code - .pas formatCVS

Pascal Programming

The basic structure of a Pascal Program

PROGRAM ProgramName (FileList);

CONST  (* Constant declarations *)

TYPE  (* Type declarations *)

VAR  (* Variable declarations *)

(* Subprogram definitions *)

BEGIN  (* Executable statements *)END.

Pascal Programming

Exercise Time

1. Open your IDE2. Create a complete “dummy” program3. Then save it on your desktop as4. Alpha.pas5. Note: No compilation is required6. Aim 1: to get hands dirty with the IDE 7. Aim 2: understand the structure of a

Pascal Program

Pascal Programming

Identifiers

Must begin with a letter from the English alphabet.

Can be followed by alphanumeric characters (alphabetic characters and numerals) and possibly the underscore (_).

May not contain certain special characters, many of which have special meanings in Pascal.~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / |

Pascal Programming

Identifiers

Pascal Programming

Pascal is not case sensitive!

Turbo Pascal allows you to write names with upper and lowercase letters.

PART_NUMBER part_number PaRt_NumBer Part_Number

Pascal would consider the above identifiers as the same.

Pascal Programming

Memory storage

Pascal Programming

Pascal Data Types

The basic data types in Pascal include:integerrealcharBoolean

Pascal Programming

Pascal Data Types

More: http://www.geocities.com/hotdogcom/ptutor/chap03.html

Pascal Programming

Variable declaration

var  IdentifierList1 : DataType1;  IdentifierList2 : DataType2;  IdentifierList3 : DataType3;  ...

var  age, year, grade : integer;  circumference : real;  LetterGrade : char;  DidYouFail : Boolean;

Pascal Programming

Input and Output

Input from keyboardReadln(var);

Output to screenWriteln(‘Hello World!’);

Pascal Programming

The End – Thank you for your kind attention

References:http://taoyue.com/tutorials/pascal/contents.htmlB. Gottfried, Programming with Pascal, 2nd

Edition, McGrawHill

Pascal Programming

http://ashesh.ramjeeawon.infoBlog: http://asheshr.wordpress.comManagement Student/ Freelance DeveloperUniversity of MauritiusBCS Student Member