Senin, 06 Juni 2011

Introduction to Language Pascal


History of Pascal

Rooted in the language Algol and PL / 1 in the 60's in continental Europe, Pascal Wirth Prof.Niklaus compiled by and published in 70 years of 71, tested at the CDC 6000 computer is the Turbo Pascal compiler and included high-level language.

- pascal is a high-level programming language because Pascal is a structured programming language

- The name pascal was taken from the name of a mathematician Blaise Pascal

- Pascal was designed by prof. Niklaus Wirthdari Switzerland

A. Create a directory:

· File-DOS Shell-Change directory by typing "cd \ .." (Change Dir) to look like "C: \>".

· If so, at C: \> type "md nama_direktori (eg: md lely_6H).

· Then enter.

* Type exit to exit from DOS

B. Fox Directory:

· File-Change Dir C-2x-click search directory name of each

· Repeat this every time you start pascal allows for all the exercises are stored in individual folders.

C. Starting a new program:

· File-New

· Saving Files:

· File-Save-Type the name of the file

· Explain Pascal Program Structure:

Pascal Language Structure

§ Title

<judulnya> Program;

Uses <unitnya>;

§ Section Declaration

Label <namalabelnya>;

Const <nama=nilai constantanya>;

Type <namatype:typedatanya>;

Var <nama_variabelnya>;

Procedure <nama_prosedurnya>;

Function <nama_fungsinya>;

§ Section Statement

Begin

<pernyataan-pernyataan>;

End.


1. Program Title

2. Block Program, consisting of:

§ The Declaration: variables, constants, labels, type, fungsidll

§ The statement: Begin Begin and end dg dg End. / content program

· Compile / Compiling, Process to check whether the program instruction error is correct / not yet. How: Compile-compile/Alt + F9

· Run, The process to compile once run the program. How: Run-run/Ctrl + F9

· Showing results program: ALT + F5

· Cleaning the screen / display: Clrscr (Clear Screen), using the procedure Crt Uses (Uses Catode Ray Tube).

· Extentation Pascal:. PAS

1. The command I / O

Entering data / input: Read = Enter data in the same row. Readln = Enter data per line.

Showing results / outputs: Write = Displays the output in the same row. Writeln = Displays the output line.

I2. Variables and Constants

Variable è worth of data changing in the program.

BU: Var Identifier: type of data.

È constants whose value data remain in the program.

BU: Const Identifier = value.

3. Reserved Word / Words Reserves

è are words which have been defined by turbo-pascal. Example: Program Begin, End, Var, Const etc.

Ex: an introductory program pascal;

Uses crt;

Begin

Writeln ('Meeting 2 ');

Writeln ('Pascal');

Write ('Meeting 2');

Write ('Pascal');

Readln;

End.

Ex: Program introduction 2;

Uses crt;

Const

Name = 'name each';

Class = 'class each';

Var

campus: string;

Begin

Clrscr;

Writeln ('You Campus Location:'); readln (campus);

Readln

End.


Exercise!

Exercise program;

Uses crt;

Const

campus = 'Margonda';

Var

name: string [20];

class: string;

Begin

Clrscr;

Write ('NAME:'); readln (name);

Write ('CLASS'); readln (class);

Writeln ('You Campus Location:', campus);

Readln

End.

Sample Program


The program listing

Uses Crt;

Begin

Writeln ('I');

Write ('Learning');

Writeln ('Turbo');

Write ('Pascal');

Write ('Version 7.0');

End.

Press Ctrl + F9 to ekseskusi program

Press F5 to see results

The result:

I

Turbo Learning

Pascal Version 7.0

source by http://dif4jc.wordpress.com

Tidak ada komentar:

Posting Komentar