Kamis, 19 Mei 2011

PASCAL PROGRAMMING LANGUAGE

1. History PASCAL

is the development of the language ALGOL 60, the programming language for scientific computing. In 1960, some computer experts work to develop a language of ALGOL, one of them is Dr. Niklaus Wirth of the Swiss Federal Institute of Technology (ETH-Zurich), which is a member of the group that makes ALGOL. In 1971, he published a specification for the highly-structured language (high-structured language) that resemble ALGOL. He was named to the PASCAL (a philosopher and mathematician from France), Pascal is data oriented, ie the programmer was given freedom to define their own data. Pascal is also the teaching language (widely used for teaching programming concepts.) Other advantages are a graceful writing Pascal code, not such as FORTRAN, which requires programmers to write code with a specific format. The basic form Pascal program is as follows: TITLE program; begin statement; pernyataanend.

2. PASCAL

as a structured language structured as language, PASCAL has the following characteristics: 1. Sequential composition of the codes in Pascal text should be written in order from above, the statements that were written early will be executed first. Therefore, any statement relating to a variable in the program, then the variable must be defined first before. This was mainly related to the calling sub-program by another sub-program. Can be read further in the sub-program.2. Aligned with the limits that clear.Pascal provide a clear boundary on each block, as in the main program blocks, sub-program, control structures (repetition / selection), etc.. Use keywords begin to commencement of operations on the block and the end to close a programmer would compile the program with ease. As an example: If X> 0 thenbegin Write ('positive number'); Writeln ('program finished'); end; 3. One entrance and one exit on the block selection and repetition. The above example also illustrates the single entrance to a block selection that is a logic test X> 0, with a single output gate as well (one here means not two but a command-line output was carried out together with packet command begin .. end.3. Bakuan PASCALDibakukan by ISO in 1983 and developed in several versions, including: USCD PASCAL, MS PASCAL, TURBO PASCAL etc.. With the growing technology in computing, Pascal utilized for the development of DELPHI (derived from the name of a city in ancient Greece), a language visual programming that highlight the graphic effects and orientation of objects that are ready to wear, because it has the Visual Component Library (VCL) .4. PASCAL language structure in general, Pascal has a structure as follows: 1. Section Title program2. Section Declaration. Declaration of data types (TYPE) b. Declaration of the variables (VAR) c. Declaration of constants (const) d. Declaration label (LABEL) e. Declaration sub-programs (PROCEDURE and FUNCTION) 3. Section Main Program Perintah.Teks Pascal least have the title of the Program, the Declaration, and Section Main Program in the form of commands. As for the declaration conform with the contents of the program itself. Examples of PASCAL programs: programs TAMBAH_00; {Summing the two numbers whose value is given in the command} var X, Y, Z: integer; {Declaration of variables X, Y and Z as integer} BEGIN {Main Program Start} X: = 50; { The command gives a value of 50 in var. X} Y: = 25; {command gives the value 25 in var. Y} Z: = X + Y; {Commands add X and Y and stores the result into Z} END. {End of Main Program} In this example the value of X and Y could not be any, because of certain defined. For the value of X and Y can be freely determined, the value of X and Y are read from the default input.program ADDED_01; {Summing the two numbers are read from the default input} var X, Y, Z: integer; {Declaration of variables X, Y and Z as integer} BEGIN {Main Program Start} read (X); {Reading the value of X through the key-board} read (Y); {Reading the value of Y through the key-board} Z: = X + Y; {Sum X and Y and save the result to Z} write (Z); {Presents a Z to the screen} END. {End of Main Program} Basic Language PASCAL Programming Elements. Getting the data by reading data from the default input (key board, files or other data sources). B. Storing data into memory with the appropriate data structure, c. Process data with instructions that tepat.d. Present or send the processed data to default output (monitor, file or other purposes). In the process the necessary data management structured instruction: a. Some instructions are grouped in one block or model tertentu.b tasks. Some commands executed with the requirements certain.c. Some commands executed repeatedly with a certain amount of repetition. Identifier Used to name: Program, Sub-programs (procedures and functions), name: Variable, Constant, Type, Label.Names It is used for consumption and callings in the program. Terms of writing identifiera. Identifier name must begin with the alphabet characters: a through z, A to Z or the character '_' (underscore - bottom line) b. The next character numeric characters allowed (0 .. 9) or a combination of alphanumeric (letter-numeric). C. Long name, in various versions of Pascal is generally between 32 - 63.d. May not use special characters: + - * / \ = <> []. ,;: () ^ @ {} $ # ~! % & `" 'And? Examples of writing: Writing is true: X _PQR Beta broad Angle_Alpha Circle Writing wrong: 3D B-Right side # Type identifiera. Common identifier is the identifier that is defined solely by the programmer. Programmers have the freedom to determine identifiernya name, provided that name is not the same as the standard identifier and the reserved word that will be discussed further. This is to prevent errors that could arise due to overlaps in program.b identifier. Identifier Standard (Standard) is the identifier that is defined by the Pascal compiler makers. Usually the compiler maker provides a library that already exists in the compiler. Library contains a variety of procedures, functions or units that are ready to use. For example Turbo Pascal Windows 1.5 has a unit for processing the output of wincrt, gotoxy, which can easily be used by programmers in the writing program codes. Standard Identifier Named as a compiler does not have to have it, each compiler is possible to have different identifiers for a similar task. For example Turbo Pascal DOS version uses crt to perform the same function with wincrt (TPW 1.5). Some are owned by the Standard Identifier Pascal compiler-compiler include: abs arctan boolean eof char dispose eoln cos exp ln integer input false maxint new odd page Ord output pred pack read readln real reset rewrite round sin sqr sqrt succ writelnc write text to true trunc. Identifier "reserved word", which is already defined and used by the PASCAL language itself (We can not call us with this identifier). And array begin case const div do downto else end file for forward function goto if in label mod nil not of or packed procedure program record repeat set then to type while withDeklarasi Until var Variable: Declaring variables are: a. Provide a variable name as identity recognition. Determine the data type variable Example variable declarations: var K: integer; R: real; C: char; T: boolean; Some kind of identifier that can be declared together with. Var i, j, k: integer; {variable i, j and k as integer} name of the MHS, MHS address: char; {Name and address of the student} Constant Declaration: Declare constants are: a. Provide constant names as identity pengenalb. Determining the value of the constant example of the constant declaration: const MaximumSize = 100; {integer} ExitCommand = 'Q'; {char} type DataTipe data provided by PASCAL include: 1. Simple Data Type is the basic data types that are often used by the program, including: integer (integer), real (fraction), char (alphanumeric and punctuation), and boolean (logic). For integer and real data each divided into several kategoria. Integer numbers are integer data types, divided into several categories as shown in table 1. Table 1 shows the data types, sizes and ranges in memory value.tabel 1. IntegerTipe Numbers Data Type Data Size Range NilaiByte1 Places byte0 s / d +255 byte Shortint1-28 s / d +127 integer2 32,768 bytes-s / d 32767Word2 bytes0 s / d 65535Longint4 bytes2147483648 s / d 2147483647Contoh integer is: 34 6458 1112 -90 0 Classification of integer data type is intended to limit the memory allocation is needed for example for a calculation of a variable number of 32 767 estimated maximum value we simply declare a variable as an integer number (2 bytes), rather than as longint (4 bytes). In the compiler, Pascal provides the constants for Integer numbers are: MaxInt and MaxLongInt, the programmer could use it in the program without having to first meaning.-32 767-worth MaxInt MaxLongint 2,147,483,647 worth. example: Program display_maxint; uses wincrt; begin Writeln (maxint) end.The results: 32.767b. Numbers real or apparent is the kind of fractions, can be written in ordinary or scientific model. Examples of real numbers: +11 34 265 35.997E 0.0 -3.55, where E is the symbol of powers of 10. So have a value equal to 452.13 4.5213e2. Classification of data type real numbers can be seen in the table 2.tabel 2. Numbers RealTipe Place Size Data Range Real value l6 bytes2.9 x 10-39 s / d 1.7 x1038single4 bytes1.5 x 1045 s / d 3.4 x 1038double8 bytes5.0 x 10-324 s / d 1.7 x 10308extended10 bytes3.4 x 10-4932 s / d 1.1 x 104932comp8 bytes-9.2x 1018 s / d 9.2x 1018c. Chartipe this data store character typed from the keyboard, has 266 kinds listed in the table ASCII (American Standard Code for Information Interchange). Example: 'a' 'B' '+', etc.. To remember that in writing should be using single quotes. These data types require a memory allocation of 1 (one) for each byte of data.

http://opante.blogspot.com/2007/10/bahasa-pemrograman-pascal.html

Tidak ada komentar:

Posting Komentar