1 / 15

A Simple Program

A Simple Program. CPSC 110 - Pascal Brent M. Dingle Texas A&M University 2001, 2002. Topics to be seen. Reserved Words and Identifiers Program Body. A Program. PROGRAM HowdyAll; BEGIN writeln(‘Howdy all !’); END. Simple enough? But what does it mean?. The first line.

ronm
Download Presentation

A Simple Program

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. A Simple Program CPSC 110 - PascalBrent M. DingleTexas A&M University2001, 2002

  2. Topics to be seen • Reserved Words and Identifiers • Program Body

  3. A Program PROGRAM HowdyAll; BEGIN writeln(‘Howdy all !’); END. Simple enough? But what does it mean?

  4. The first line • PROGRAM HowdyAll; • This is the program heading or program declaration. • It has 3 parts: • the reserved word program • the name of the program – an identifier • and lastly a semicolon • All Pascal programs begin with a line like this.

  5. Reserved Words • Some words have a predefined meaning in Pascal that cannot be changed – these words are called reserved words. • Examples of Reserved words are:PROGRAM, BEGIN and END

  6. Standard Identifiers • Other words in Pascal have predefined meanings but their meaning can be changed – these words are called standard identifiers. • An example of a standard identifier is:writeln

  7. Case (In)Sensitivity • Pascal does NOT care if you use capital letters in your words. • To it the words:BEGIN, BegIN, and BeGinare all the same.

  8. Program Body • The reserved words BEGIN and END mark the body of the program you just saw, back several slides. • Notice the period after the END. • All Pascal programs will end that way.

  9. Writeln • writeln is a procedure in Pascal. • It is pronounced write-line. • Inside the parentheses of the writeln is a string. • A string is marked at the beginning and end with single quote marks.

  10. The program’s output • When you compile and run the program you will see the below output on the screen (note you may have to go to the user screen to see it)Howdy all !

  11. Strings • Strings are sequences of characters you want the program to treat as one object. • Usually strings are composed of letters, digits, punctuation marks, spaces, and other symbols from the keyboard.

  12. String creation • To create a string place single quote marks at the beginning and end of the characters that you wish to group together. • The single quote marks are called delimiters.

  13. String examples • ‘Howdy all !’ • ‘Purple People Eater’

  14. The single quote in a string • To place the single quote in a string you type the single quote twice. For example:‘Purple People Eaters don’’t exist.’ • Note that don’’t is using TWO single quotes – NOT a double quote.

  15. End of A Simple Program

More Related