Pascal By: Liane Tom. Outline o Background o Data types and Syntax o Procedures and Functions o Advantages o Disadvantages.

Slides:



Advertisements
Similar presentations
Chapter 6 Type Checking. The compiler should report an error if an operator is applied to an incompatible operand. Type checking can be performed without.
Advertisements

Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
ISBN Chapter 7 Expressions and Assignment Statements.
Ryan Piercy Jon Hooker. Invented by Nicklaus Wirth Named After Blaise Pascal Pascal’s Triangle Invented a Digital Computer.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Introduction to a Programming Environment
Chapter 2: Introduction to C++.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Pascal Programming Pascal Units, Abstract Data, Ordinals, Arrays.
FOR DOWNTO Suppose you want to write a FOR-DO loop where the control variable is decreased with each repetition of the loop. Pascal provides the reserved.
MT311 Java Application Programming and Programming Languages Li Tak Sing ( 李德成 )
Block-Structured Procedural Languages Lecture 11: Dolores Zage.
PASCAL. HISTORY OF PASCAL Developed by Niklaus Wirth a member of the International Federation of Information Processing(IFIP) To provide features that.
Names Variables Type Checking Strong Typing Type Compatibility 1.
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
CS2311 Computer Programming Dr. Yang, Qingxiong (with slides borrowed from Dr. Xu, Henry) Lecture 2: Basic Syntax – Part I: Variables and Constants.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Lecture #5 Introduction to C++
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
CS 153: Concepts of Compiler Design October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
Arithmetic Expressions
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
CS 153: Concepts of Compiler Design September 21 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Data Types Declarations Expressions Data storage C++ Basics.
Pascal Programming Arrays and String Type.
Oberon Oral Exam English. index The creator The history The use The syntax An example Conclusion.
1 STRINGS String data type Basic operations on strings String functions String procedures.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
CS 153: Concepts of Compiler Design September 30 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Programming with Microsoft Visual Basic th Edition
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
Chapter 3 AS3 Programming. Introduction Algorithms + data structure =programs Why this formula relevant to application programs created in flash? The.
CS 153: Concepts of Compiler Design September 23 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.
2 nd Semester Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang
Expressions and Data Types Professor Robin Burke.
Chapter 6. Character String Types It is one in which the values consists of sequences of characters. How to Define a variable contain a string? In a programming.
CS 153: Concepts of Compiler Design September 28 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Definition of the Programming Language CPRL
Pascal Programming Arrays and String Type.
Data Types In Text: Chapter 6.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Written by Al.So. Software solutions
CS 326 Programming Languages, Concepts and Implementation
Principles of programming languages 4: Parameter passing, Scope rules
Section 3.2c Strings and Method Signatures
CMPE 152: Compiler Design September 18 Class Meeting
CMPE 152: Compiler Design October 2 Class Meeting
High Level Programming Languages
The Data Element.
CMPE 152: Compiler Design February 21 Class Meeting
The Data Element.
CMPE 152: Compiler Design March 7 Class Meeting
CMPE 152: Compiler Design March 5 Class Meeting
Presentation transcript:

Pascal By: Liane Tom

Outline o Background o Data types and Syntax o Procedures and Functions o Advantages o Disadvantages

Background o Named after mathematician and philosopher Blaise Pascal. o Developed by Niklaus Wirth o Based on ALGOL o Designed to be a block-structured language for general use o It is a compiled language o Developing and testing programs might take longer than other languages. o Designed for teaching programming to computer science, engineering, and science students o Used for undergraduate courses until the late 1990s

Data Types and Syntax o Reserved words o AND, ARRAY, BEGIN, CASE, CONST, DIV, DO, etc. o Predefined identifiers o Programmer can change meaning o boolean, char, integer, real, text, false, etc. o Ordinal Data Types o Integer, char, and boolean o Data are countable, each has a unique predecessor and successor, and they can be ordered and compared o User-Defined Types o Frequently referred to as enumerated types o TYPE Weekday = (Mon, Tues, Wed, Thur, Fri); VAR Day : Weekday;

Data Types and Syntax Cont’d o String constants o If a word of one or more characters is used. o Defined in the CONST portion of the declaration section. o Entire string must be enclosed in single quotation marks. o Ex. CONST Name = ‘Liane Tom’; Date = ‘May 1, 2006’; o Array o Two methods to declare o VAR List : ARRAY[1..5] OF integer; o TYPE Numbers = ARRAY[1..5] OF integer; VAR List : Numbers;

Data Types and Syntax Cont’d o Records o A collection of fields that may be treated as a whole or individually o Ex. VAR Customer : RECORD Name : Array [1..30] OF char; Age : integer; AnnualIncome : real; END;

Data Types and Syntax Cont’d o Sets o Structured data type consisting of a collection of distinct elements from an ordinal base type o TYPE type name = SET OF base type; VAR variable name = type name; o Ex. TYPE Alphabet = SET OF ‘A’.. ‘Z’; VAR Vowels, Consonants : Alphabet; o Once a set variable is declared, it is undefined until an assignment of values is made o Ex. Vowels := [‘A’,’E’,’I’,’O’,’U’];

Data Types and Syntax Cont’d o Program

Procedures and Functions o Procedures o Procedure heading instead of program heading. o PROCEDURE procedure name(parameter list); o END is followed by a semicolon instead of a period o Declared in the VAR section in the main program o Procedure heading is also an identifier, so variable identifiers cannot use the same names if they are on the same level. o Ex. PROGRAM Demo2 (output); VAR Prac : integer; PROCEDURE Prac (A : integer); o Functions o FUNCTION function name(parameter list) : return type; o Some value must be assigned to the function name in the executable section of the function o Cube := X*X*X; o Function name cannot be used on the right side of an assignment statement within the function. o Cube := Cube + 1; o In the calling program, the function name cannot be used on the left of an assignment statement.

Advantages o Simple and expressive o Program structure of the main program, procedures, and functions are all similar o Heading o Declaration section o Execution section o No restriction on the length of variable, function, or procedure names o Strongly-typed language so variables can only be assigned to the correct data type

Disadvantages o Compiled language – takes more time to develop and test small Pascal programs o Can overload variables names between main program and procedures o Not that much flexibility since it is strongly-typed o No static variables – no variable can be private to another routine and retain its value from one call of the routine to the next

Resources o Kernighan, Brian W., “Why Pascal is Not My Favorite Programming Language”. 2 Apr University of Virginia, Department of Computer Science. 11 Apr o “Modula-2”. 8 Apr Wikipedia. 11 Apr o Nance, Douglas W., Fundamentals of Pascal: Understanding Programming and Problem Solving. West Publishing Company, o “Pascal Programming Language”. 11 Apr Wikipedia. 11 Apr o Sebesta, Robert W., Concepts of Programming Languages. 7th ed. Pearson Education, Inc., 2006.