1 / 13

Pascal

Pascal. Regina Bellamy Katitia Eaddy Corinthia Cunningham Anthony Mancuso. Problem Domain. Designed to be efficient and concise First developed for instructional use Later extended for more wide-spread use. Historical Context.

gbrinkley
Download Presentation

Pascal

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pascal Regina Bellamy Katitia Eaddy Corinthia Cunningham Anthony Mancuso

  2. Problem Domain • Designed to be efficient and concise • First developed for instructional use • Later extended for more wide-spread use

  3. Historical Context • Developed by Nicklaus Wirth after Algol-W passed up for Algol-68 • Named after Blaise Pascal, a French mathematician • Direct descendent from Algol-60 and Algol-W in 1971 • Used from the late 60s to the late 80s for teaching programming, which it was originally designed for

  4. Evolution of the Language • Pascal was extended to better support the needs of programmers • Pascal-P (Portable) was created to allow code to be ported to various operating systems (virtual machine!) • Borland and Apple created object-oriented extensions in the 1990s • Borland then created Delphi, which uses Pascal as its programming language • ML and Modula are descended from Pascal

  5. Language Concepts • Case-insensitive • Semicolon as a separator • Functions and procedures • Variable-length strings vs. arrays of characters • Record (borrowed from COBOL) • Repeat..until (do..while in C) • In

  6. Example 1 – A Sample Program Program ArithFunc; const Sentinel = 0.0; var X : Real; begin writeln(‘Enter a real number, 0.0 to stop’); writeln; writeln(‘X’, ‘Trunc(x)’ :16, ‘Round(x)’ :10, ‘Sqrt(Abs(X))’ :15); readln(X); while X <> Sentinel do begin writeln(Trunc(X) :17, Round(X) :10, Abs(X) :10:2, Sqrt(X) :10:2); readln(X) end end. Reference: http://pascal-central.com/ppl/chapter4.html

  7. Example 2 – Using Procedures Program Something; procedure DoSomethingElse(x : real); begin writeln(‘Displaying half of your number: ’, x / 2) end; procedure DoSomething; var x : real; begin writeln(‘Enter a number.’); readln(x); DoSomethingElse(x) end; begin DoSomething end.

  8. Example 3 – While Version Program FactorialWhile; var n, fact : integer; begin writeln(‘Enter n to compute n!.’); readln(n); fact := 1; while n > 1 do begin fact := fact * n; n := n – 1 end end.

  9. Example 3 – Repeat Version Program FactorialRepeat; var n, fact : integer; begin writeln(‘Enter n to compute n!.’); readln(n); if n > 0 then begin fact := 1; repeat fact := fact * n; n := n – 1; until n = 0; end end.

  10. Example 3 – Downto Version Program FactorialFor; var n, i, fact : integer; begin writeln(‘Enter n to compute n!.’); readln(n); fact := 1; for i := n downto 1 do fact := fact * i end.

  11. Comparison to Algol • Designed to be simpler than its ancestor • Algol-60 was the first block-structured language • Foundation provided by Algol-W

  12. Comparison to C • Record vs. struct • Variable-length string vs. char[] • Begin..end vs. { } • Pascal is more strongly typed • Pascal allows nested function definitions

More Related