Learn pascal in three days

336 509 2
Learn pascal in three days

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... editing this book x About the Author Sam Abolrous is a software engineer with an extensive background in software design and program development He has a B.S in electrical engineering from the University of Alexandria, Egypt He has published articles for leading programming journals and has written over 50 books on computer science ranging from COBOL to C++ programming, including Learn C in Three Days. .. real numbers for equality Instead, it would be better to test to see if the difference between the two numbers is less than some specific small amount In Turbo Pascal, there are additional numeric types, which are introduced in the following section Numeric Types in Turbo Pascal There are additional integer types (including the type INTEGER) in Turbo Pascal They are shown in Table 2-1 along with their... standard Pascal and also how they are represented in the modern implementations such as Turbo Pascal and UCSD Pascal (using the type STRING) 2-2 Numeric Data Types The range of numbers that may be represented as integers (or as reals) depends on the implementation For the type INTEGER it is determined by the following limits: MAXINT –(MAXINT+1) the maximum positive integer the maximum negative integer... Operation Addition Subtraction Multiplication Real division Integer division Operands REAL/INTEGER REAL/INTEGER REAL/INTEGER REAL/INTEGER INTEGER Result REAL/INTEGER REAL/INTEGER REAL/INTEGER REAL INTEGER Precedence Low Low High High High Drill 1-3 Evaluate the following expressions and write the result either as an integer (if integer) or as a fixed-point real number (if real): A 15 – 15 DIV 15 B 22 + 10... statement is included inside a frame starting with the keyword BEGIN and ending with the keyword END This is called the program main body (or the program block) and usually contains the main logic of data processing Comments Consider the first line in the program: { - Example 1-1 } This is a comment and is totally ignored by the compiler Comments can appear anywhere in the Pascal. .. name in your code You can declare named constants as in the following example: CONST Pi = 3.14159; ThisYear = 1992; Department= 'OtoRhinoLaryngology'; Some constants are predefined in Pascal as standard identifiers One useful predefined named constant is MAXINT, which gives the maximum value an integer can possess The value depends on the computer used If you want to know the value of MAXINT in your... to the closest integer 6 You know how to declare named constants and use them in the program 7 During you first tour of Pascal, you learned the following output statements to display both variables and numeric or string literal constants: WRITELN WRITE Also, you learned the following input statements to read variable values from the keyboard: 18 n Chapter 1 READLN READ 8 Finally, you learned how to... program is going to produce output (such as writing to the screen), which is the counterpart of INPUT (such as reading from the keyboard) The words OUTPUT and INPUT are called file parameters The program may perform both input and output, in which case the file parameters take the form: PROGRAM FirstProgram(INPUT,OUTPUT); In Turbo Pascal the program heading is optional You may skip the whole line and start... Chapter 1 Program Heading The second line is called the program heading It starts with the keyword PROGRAM followed by a space, followed by the program name (FirstProgram) The program name is a user-invented word User-invented words are classified in Pascal as identifiers An identifier must begin with a letter and may contain any number of letters or digits (in Turbo Pascal it may contain underscores as... Summary In this chapter you were introduced to the most important tools in Pascal programming 1 You are now familiar with the Pascal program structure: n The program heading n The declaration part n The CONST section n The VAR section n The program main body between BEGIN and END 2 You know two important data types, INTEGER and REAL, and how to express and evaluate arithmetic expressions using both . h0" alt="" Learn Pascal in Three Days Third Edition Sam A. Abolrous Wordware Publishing, Inc. Library of Congress Cataloging -in- Publication Data Abolrous, Sam A. Learn Pascal in three days / by. leading programming journals and has written over 50 books on computer science ranging from COBOL to C++ pro - gramming, including Learn C in Three Days and Learn Pascal from Wordware Publishing Character Input 105 Using READLN for Character Input 107 Input of Mixed Types 108 Example: Scrambling Letters 109 6-4 Reading a Line of Text: EOLN 111 Example: Character Counter 111 6-5 Reading a

Ngày đăng: 23/10/2014, 11:47

Từ khóa liên quan

Mục lục

  • Contents

  • Preface

  • Chapter 1: Hello Pascal

    • 1-1 Your First Pascal Program

      • Comments

      • Program Heading

      • Syntax and Conventions

      • 1-2 Displaying Text: WRITELN, WRITE

      • 1-3 Crunching Numbers

        • Integers and Real Numbers

        • Evaluation of Arithmetic Expressions

        • 1-4 Using Variables

          • Variable Declaration

          • The Assignment Statement

          • 1-5 Named Constants

          • 1-6 Type Conversion: ROUND, TRUNC

          • 1-7 Reading from the Keyboard: READLN, READ

          • 1-8 Formatting Output

          • Summary

          • Exercises

          • Answers

          • Chapter 2: Language Elements

            • 2-1 Standard Data Types and Functions

            • 2-2 Numeric Data Types

              • Numeric Types in Turbo Pascal

              • 2-3 Standard Arithmetic Functions

                • Example: The Power Function

Tài liệu cùng người dùng

Tài liệu liên quan