Pascal Programming Session 1

4,740 views
4,379 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,740
On SlideShare
0
From Embeds
0
Number of Embeds
37
Actions
Shares
0
Downloads
195
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Pascal Programming Session 1

  1. 1. Pascal Programming http://ashesh.ramjeeawon.info Management Student/ Freelance Developer University of Mauritius Module Pre-Requisites: Problem-Solving Techniques Session 1: Pascal Fundamentals
  2. 2. Today’s Session <ul><li>Intro to Pascal </li></ul><ul><li>History of Pascal </li></ul><ul><li>Getting the tools (IDE/Compiler) </li></ul><ul><li>The basic structure of a Pascal Program </li></ul><ul><li>Identifiers </li></ul><ul><li>Data Types </li></ul><ul><li>Input and Output </li></ul>
  3. 3. Intro to Pascal <ul><li>Pascal is a general-purpose, high-level programming language </li></ul><ul><li>Derived from Algol-60 </li></ul><ul><li>Specifically designed to encourage the use of Structured Programming </li></ul>
  4. 4. Intro to Pascal <ul><li>Pascal was named in honour of Blaise Pascal (1623 – 1662) </li></ul><ul><li>Brilliant French Scientist and Mathematician </li></ul><ul><li>Invented the word’s first calculating machine (Pascaline) </li></ul>
  5. 5. History of Pascal <ul><li>Developed in the early 1970s by Niklaus Wirth at </li></ul><ul><li>The Technical University in Zurich, Switzerland </li></ul>
  6. 6. History of Pascal <ul><li>In 1983, Borland International began marketing of an inexpensive compiler called Turbo Pascal. </li></ul>
  7. 7. Getting the tools
  8. 8. Getting the tools <ul><li>Turbo Pascal for Windows </li></ul><ul><ul><li>Getting hands dirty with the IDE </li></ul></ul><ul><ul><li>Installing the Turbo Pascal </li></ul></ul><ul><ul><li>Code writing aids </li></ul></ul><ul><ul><li>Compiling </li></ul></ul><ul><ul><li>Debugging </li></ul></ul><ul><ul><li>Saving source code - .pas format </li></ul></ul><ul><ul><li>CVS </li></ul></ul>
  9. 9. The basic structure of a Pascal Program <ul><li>PROGRAM   ProgramName  ( FileList ) ; CONST    (* Constant declarations *) TYPE    (* Type declarations *) VAR    (* Variable declarations *) (* Subprogram definitions *) BEGIN    (* Executable statements *) END. </li></ul>
  10. 10. Exercise Time <ul><li>Open your IDE </li></ul><ul><li>Create a complete “dummy” program </li></ul><ul><li>Then save it on your desktop as </li></ul><ul><li>Alpha.pas </li></ul><ul><li>Note: No compilation is required </li></ul><ul><li>Aim 1: to get hands dirty with the IDE </li></ul><ul><li>Aim 2: understand the structure of a Pascal Program </li></ul>
  11. 11. Identifiers <ul><li>Must begin with a letter from the English alphabet. </li></ul><ul><li>Can be followed by alphanumeric characters (alphabetic characters and numerals) and possibly the underscore (_). </li></ul><ul><li>May not contain certain special characters, many of which have special meanings in Pascal. ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : &quot; ; ' < > ? , . / | </li></ul>
  12. 12. Identifiers
  13. 13. Pascal is  not  case sensitive! <ul><li>Turbo Pascal allows you to write names with upper and lowercase letters. </li></ul><ul><li>PART_NUMBER part_number PaRt_NumBer Part_Number </li></ul><ul><li>Pascal would consider the above identifiers as the same. </li></ul>
  14. 14. Memory storage
  15. 15. Pascal Data Types <ul><li>The basic data types in Pascal include: </li></ul><ul><li>integer </li></ul><ul><li>real </li></ul><ul><li>char </li></ul><ul><li>Boolean </li></ul>
  16. 16. Pascal Data Types More: http://www.geocities.com/hotdogcom/ptutor/chap03.html
  17. 17. Variable declaration <ul><li>var    IdentifierList1   :   DataType1 ;    IdentifierList2   :   DataType2 ;    IdentifierList3   :   DataType3 ;    ... </li></ul><ul><li>var   age, year, grade : integer;   circumference : real;   LetterGrade : char;   DidYouFail : Boolean; </li></ul>
  18. 18. Input and Output <ul><li>Input from keyboard </li></ul><ul><li>Readln(var); </li></ul><ul><li>Output to screen </li></ul><ul><li>Writeln(‘Hello World!’); </li></ul>
  19. 19. The End – Thank you for your kind attention <ul><li>References: </li></ul><ul><ul><li>http://taoyue.com/tutorials/pascal/contents.html </li></ul></ul><ul><ul><li>B. Gottfried, Programming with Pascal, 2 nd Edition, McGrawHill </li></ul></ul>
  20. 20. http://ashesh.ramjeeawon.info Blog: http:// asheshr.wordpress.com Management Student/ Freelance Developer University of Mauritius BCS Student Member

×