Monday, December 10, 2007

How to work with CLRSCR

How to work with CLRSCR

To work with CLRSCR

Description:

Clears the screen and returns the cursor to the upper left corner.

Declaration:

procedure ClrScr;

Example:

program Welcome;

uses

Crt;

var

a:file;

begin

TextBackground(LightGray);

ClrScr;

end.

Edited By: Norasyikin Mahmud

© 2001 ISC

All rights reserved. All other product names and trademarks are registered properties of their respective owners.

211101


How to work with Close command

How to work with Close command

To work with Close command

Description:

Closes an open file.

Declaration:

procedure Close(var F);

Example:

program Welcome;

var

a:file;

begin

Assign(a,'\AUTOEXEC>BAT');

Reset(a,1);

Writeln('File size= ',FileSize(a));

Close(a);

end.

How to work with Assign command

How to work with Assign command

To work with Assign command

Description:

Assigns the name of an external file to a file variable.

Declaration:

procedure Assign(var F; Name);

Example:

program Welcome;

var

a:text;

begin

Assign(a,'');

Rewrite(a);

Writeln(a,'standard output...');

Close(a);

end.

How to work with Arc by example

How to work with Arc by example

To work with Arc by example

Example:

program Welcome;

uses

Graph;

var

a,b:integer;

radius:integer;

begin

a:=Detect;

initgraph(a,b,'')

if GrapResult<> grOK then Halt(1);

for Radius:=1 to 5 do

Arc(100,100,0,90,Radius*10);

Readln;

CloseGraph;

end.

How to work with Arc

How to work with Arc

To work with Arc

Description:

The Arc function draws an elliptical arc.

Declaration:

Arc(DC: HDC; X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer): Bool;

How to work with Abs by example

How to work with Abs by example

To work with Abs by example

Example:

program Welcome;

uses

WinCrt;

var

r:integer;

t:real;

begin

r:=Abs(-100);

t:=Abs(-1.2);

Write(r,t);

end.

Output:

How to work with Abs functions

How to work with Abs functions

To work with Abs functions

Description:

Returns the absolute value of the argument.

Declaration:

Abs(x);

How to build the project

How to build the project

To build the project

Step 1

To build the project, the first thing you need to do is to use the mouse to open the Compile menu and then click the Build command.

Step 2

Next, you could see that the program contains no errors.

How to make the project

How to make the project

To make the project

Step 1

If you wish to make the project, first, you need to use the mouse to open the Compile menu and then click the Make command.

Step 2

Next, you can see that the program has no errors.

How to run the project

How to run the project

To run the project

Step 1

To run the project, the first thing you need to do is to use the mouse to open the Run menu and then click the Run command.

Step 2

Then you can see that the project is being run.

How to compile the Pascal project

How to compile the Pascal project

To compile the Pascal project

Step 1

To compile the pascal project, first, you need to use the mouse to open the Compile menu and then click the Compile command.

Step 2

Now, you can see that the program is compiled and does not have any errors.

How to open the *.pas file

How to open the *.pas file

To open the *.pas file

Step 1

If you would like to open the *.pas file, first, you need to use the mouse to open File menu and then click the Open command.

Step 2

Next, you can enter the file name and you can also select the file name in the Files list box.

Step 3

Now, the Pascal file is being opened.


How to start with Turbo Pascal project

How to start with Turbo Pascal project

To start with Turbo Pascal project

Program à program header

Var à declarations

Begin à Start of the processing or action portion of the program.

…….. à Statement to accomplish the program’s task.

End à end of the programm

How to work with ARRAY by example

How to work with ARRAY by example

To work with ARRAY by example

Example:

program Welcome;

uses

WinCrt;

var

count,sum:integer;

mark:array [1..40] of integer;

begin

for count:=1 to 12 do

begin

mark[sum]:=count+2;

Writeln(mark[sum]);

end;

end.

Output:

How to work with ARRAY

How to work with ARRAY

To work with ARRAY

Description:

Array is a structured group of like elements given a common name.

Declaration:

array [index-type] of element-type

How to work with Record data type bye Example

How to work with Record data type bye Example

To work with Record data type bye Example

Example:

program Welcome;

uses

WinCrt;

type

student=record

StudentNo:longint;

StudentName:string;

Department:string;

end;

var

mystudent:student;

begin

Writeln(' Please Enter your student information.');

Write(' Student No: ');

Readln(mystudent.StudentNo);

Write(' Student Name: ');

Readln(mystudent.StudentName);

Write(' Department: ');

Readln(mystudent.Department);

Writeln(' ');

Writeln('************************** Student Information *******************************');

Writeln('Student No: ',mystudent.StudentNo);

Writeln('Studnet Name: ',mystudent.StudentName);

Writeln(' Department: ',mystudent.Department);

Writeln('*******************************************************************************');

end.

Output:


How to work with record data type

How to work with record data type

To work with record data type

Description:

The components of a record are called fields. Each field has its own field identifier and type

Declaration:

type

student=record

StudentNo:longint;

StudentName:string;

Department:string;

end;

How to work with Boolean operators by example

How to work with Boolean operators by example

To work with Boolean operators by example

Example:

program Welcome;

uses

WinCrt;

var

player1:integer;

player2:integer;

begin

Writeln(' Player 1 please enter the number: ');

Read(player1);

Writeln(' Player 2 please enter the number: ');

Read(player2);

if (player1 > player2) or (player1 >= player2) then

Writeln(' The winner is player 1');

if (player1 <>

Writeln(' The winner is player 2');

end.

Output:

How to work with Boolean operators

How to work with Boolean operators

To work with Boolean operators

Boolean operators are the special operators, which are used to combine Boolean expressions;

Operator Operation

not negation

and logical and

or logical or

xor logical xor


How to work with the Boolean Expressions by example

How to work with the Boolean Expressions by example

To work with the Boolean Expressions by example

Example

program Welcome;

uses

WinCrt;

var

player1:integer;

player2:integer;

begin

Writeln(' Player 1 please enter the number: ');

Read(player1);

Writeln(' Player 2 please enter the number: ');

Read(player2);

if player1 > player2 then

Writeln(' The winner is player 1');

if player1 <>

Writeln(' The winner is player 2');

if player1 = player2 then

Writeln(' No winner in this game ');

end.

Output: