1 / 12

Algorithm & programming

Learn the basics of Pascal programming, including reserved words, identifiers, data types, and program structure. Explore sample programs like printing a welcoming message and adding two numbers.

cheriec
Download Presentation

Algorithm & programming

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. Algorithm & programming Ch.2 Introduction to Pascal Programming Introdaction to Pascal programming

  2. Sample programs • Print a welcoming message • Introducing yourself to the computer • Adding two numbers Introdaction to Pascal programming

  3. A. Reserved Words(p.28) • These words have been assigned special meanings and cannot be changed E.g. And, Div, For, Begin, end, var, case, if, then , else, while, const, integer, string, boolean…etc Introdaction to Pascal programming

  4. B. Identifiers • Standard e.g. write, writeln, read, real…etc • User-defined e.g.Num2, Sum, AddTwoNumbers…etc • No space, symbol • Begin with letter E.g. EndOfPaper p.44(1) Introdaction to Pascal programming

  5. C. Punctuation Marks & Symbols • :=, :, <, >, +, -(negative sign or minus), *, /, ?, ( ), “”, . Introdaction to Pascal programming

  6. D. Numbers, characters & strings • Integers and real numbers(real) • Characters(char) • Strings Introdaction to Pascal programming

  7. Data Type • Integer • -3276832767 • Real • Floating point notation=mantissa+exponent • 123.45=1.2345E+02 • 15.2,123.0, 0.00000012 • Char • ‘‘, ‘E’, ‘%’ • String • ‘Our’, ‘Our Lady’s’, ‘35.7’, null • Maximum: 255 char Introdaction to Pascal programming

  8. E. Comment/Remarks • They do not perform any action • They gives information to the programmer • They cannot be inserted in the middle of words • E.g. (*Test marks calculation*) (*Input of marks*) {The following program help us to ,,,} p.30 Introdaction to Pascal programming

  9. Program • Program heading • E.g. prog CheckPass (input, output) • Declaration part • Constant Declaration • Variable Declaration • Procedure Declaration • Program body • begin…End. p.33 Introdaction to Pascal programming

  10. Program headings • Specifies a name for the program • Program Welcome, • Program AddTwoNumbers; • Program Introduce(input, output); Introdaction to Pascal programming

  11. Declaration • Constant definition • Const Rate=0.08; • Pi=3.14159; • MaxNo=100; • Variable definition • Num1, Num2, Sum :integer; • Name:string; • Amount, Interest: real; • Found: boolean; Introdaction to Pascal programming

  12. Programming Exercises • Print your email address • Print your class time table • Print with the following sample output using the constant ‘Computer’: Introdaction to Pascal programming

More Related