150 likes | 159 Views
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.
E N D
A Simple Program CPSC 110 - PascalBrent M. DingleTexas A&M University2001, 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 • 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.
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
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
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.
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.
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.
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 !
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.
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.
String examples • ‘Howdy all !’ • ‘Purple People Eater’
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.