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:

How to work with relational operators

How to work with relational operators

To work with relational operators

A sequence of identifiers, separated by compatible operators, that evaluates to TRUE or FALSE

Operator Operation

= Equal

<> Not equal

<>

> Greater than

<>

> Greater or equal


How to work with FUNCTION by example

How to work with FUNCTION by example

To work with FUNCTION by example

Example:

program Welcome;

const

k=' type in the number of squares to be summed ';

p=' is the sum of the first ';

var

numbertosum:integer;

answer:integer;

function sumofsquares(n: integer): integer;

var

i:integer;

sum:integer;

begin

sum:=0;

for i:=1 to n do

sum:=sum+i*i;

sumofsquares:=sum

end;

begin

Writeln(k);

readln(numbertosum);

answer:=sumofsquares(numbertosum);

Writeln(answer,p,numbertosum,' square ');

end.

How to work with FUNCTION

How to work with FUNCTION

To work with FUNCTION

Description:

The function is a subprogram called form within an expression that returns a value through the function name.

Declaration:

function ident (parameters) : type;

How to work with CONST by example

How to work with CONST by example

To work with CONST by example

Example:

program Welcome;

uses

Wincrt;

const

myname='Kenny John';

age= ' I am 17 years old ';

gender=' I am Female ';

begin

Writeln(myname);

Writeln(age);

Writeln(gender);

end.

Output:

How to work with CONST command

How to work with CONST command

To work with CONST command

Description:

The const is defines an identifier that denotes a constant value within the block containing the declaration.

Declaration:

identifier = expression;

How to work with string by example

How to work with string by example

To work with string by example

Example:

program Welcome;

uses

Wincrt;

var

a:String;

begin

Writeln('Enter the you name: ');

Readln(a);

Writeln('Name: ',a);

end.

Output:

How to work with string

How to work with string

To work with string

Description:

A string type variable is a sequence of characters with a dynamic length, and a constant maximum size between 1 and 255.

Declaration:

string [ constant ]

How to work with char by example

How to work with char by example

To work with char by example

Example:

program Welcome;

uses

Wincrt;

var

a:char;

begin

Writeln('Enter the you name: ');

Readln(a);

Writeln('Name: ',a);

end.

Output:

How to work with char

How to work with char

To work with char

Description:

Character constants are written between single quotes.

Declaration:

char [ constant ]

How to work with CASE by example

How to work with CASE by example

To work with CASE by example

Example:

program Welcome;

uses

Wincrt;

var

a:char;

begin

Writeln('Enter the char: ');

Read(a);

case a of

'm': Writeln('You are the boy');

'f': Writeln('You are the girl');

end;

end.

Output:

How to work with CASE function

How to work with CASE function

To work with CASE function

Description:

The case statement consists of an expression (the selector) and a list of statements, each prefixed with a case.

Declaration:

case expression of

case: statement;

...

case: statement;

end

How to work with REPEAT...UNTIL by example

How to work with REPEAT...UNTIL by example

To work with REPEAT...UNTIL by example

Example:

program Welcome;

uses

Wincrt;

var

x:real;

y:real;

begin

Writeln('Table of Function Values ');

Writeln;

Writeln;

Writeln(' average ',' value of formula ',' status ');

x:=0.00;

Repeat

y:=(x*x*x+7*x-1)/(x*x-(x+5)/3);

Writeln;

Write(x,'',y);

if y>=0 then Write(' Admit ');

Writeln;

x:=x+0.50

Until x >=4.00;

Writeln;

Writeln('The table is finished ');

end.

Output:

How to work REPEAT ... UNTIL function

How to work REPEAT ... UNTIL function

To work REPEAT ... UNTIL function

Description:

The statements between repeat and until are executed in sequence until, at the end of a sequence, the Boolean expression is True.

Declaration:

repeat

statement;

statement;

...

statement

until expression


How to work with FOR … DOWN TO function

How to work with FOR … DOWN TO function

To work with FOR … DOWN TO function

Example:

program Welcome;

uses

Wincrt;

var

number:integer;

sqnumber:integer;

begin

for number:=9 downto 4 do

begin

sqnumber:=number*number;

Writeln(number,' ',sqnumber)

end

end.

Output:

How to work with FOT…TO by example

How to work with FOT…TO by example

To work with FOT…TO by example

Example:

program Welcome;

uses

Wincrt;

var

number:integer;

sqnumber:integer;

begin

for number:=4 to 9 do

begin

sqnumber:=number*number;

Writeln(number,' ',sqnumber)

end

end.

Output:

How to work with FOR … TO statements

How to work with FOR … TO statements

To work with FOR … TO statements

Description:

The FOR statement is a looping construct designed specifically for count-controlled loops.

Declaration:

FOR variable identifier:= Expressionl TO Expression2 DO

Statement 1;

Statement 2;

How to work with While by example

How to work with While by example

To work with While by example

Example:

program Welcome;

uses

Wincrt;

var

x:real;

y:real;

begin

Writeln('Table of Function Values ');

Writeln;

Writeln;

Writeln(' average ',' value of formula ',' status ');

x:=0.00;

While x <=4.00 do

begin

y:=(x*x*x+7*x-1)/(x*x-(x+5)/3);

Writeln;

Write(x,'',y);

if y>=0 then Write(' Admit ');

Writeln;

x:=x+0.50

end;

Writeln;

Writeln('The table is finished ');

end.

Output:

How to work while statements

How to work while statements

To work while statements

Description:

The while statements like the IF statements, tests a condition.

Declaration:

WHILE Boolean expression DO

Statements 1;

Statements 2;

How to work with IF-THEN-ELSE example

How to work with IF-THEN-ELSE example

To work with IF-THEN-ELSE example

Example:

program Welcome;

uses

Wincrt;

var

a:integer;

begin

Writeln('Enter the two number: ');

Read(a);

if a > 10 Then

Writeln(' This integer is more then 10')

Else

Writeln(' This integer is small then 10');

end.

Output:

How to work with IF-THEN-ELSE

How to work with IF-THEN-ELSE

To work with IF-THEN-ELSE

Description:

It’s actually, the ability to make a decision.

Declaration:

IF Boolean expression

THEN

Statements 1

ELSE

Statements 2;

Statements;

How to work with IF_THEN example

How to work with IF_THEN example

To work with IF_THEN example

Example:

program Welcome;

uses

Wincrt;

var

a:integer;

begin

Writeln('Ente the two number: ');

Read(a);

if a > 10 Then

Writeln(' This interger is more then 20');

end.

Output:

How to work IF-THEN statements

How to work IF-THEN statements

To work IF-THEN statements

Description:

It’s actually the ability to make decisions.

Declaration:

- IF Boolean expression

- THEN

- Statements 1;

- Statements 2;

How to work with the Binary Arithmetic Operators div and mod

How to work with the Binary Arithmetic Operators div and mod

To work with the Binary Arithmetic Operators div and mod

Example:

program Welcome;

uses

Wincrt;

var

a:integer;

b:integer;

begin

Writeln('Ente the two number: ');

Read(a);

Read(b);

Writeln('Answer is : ',a div b);

Writeln('Answer is : ',a mod b);

end.

Output:

How to work with the Binary Arithmetic Operators

How to work with the Binary Arithmetic Operators

To work with the Binary Arithmetic Operators

Example:

program Welcome;

uses

Wincrt;

var

a:integer;

b:integer;

c:integer;

begin

Writeln('Ente the three number: ');

Read(a);

Read(b);

Read(c);

Writeln('Answer is : ',a+b+c);

Writeln('Answer is : ',a*b*c);

Writeln('Answer is : ',a+b-c);

end.

Output:


How to work with Binary Arithmetic Operators

How to work with Binary Arithmetic Operators

To work with Binary Arithmetic Operators

Description.

Operator Operation

+ Addition

- Subtraction

* Multiplication

/ Division

div Integer division

mod remainder


How to work with the data type

How to work with the data type

To work with the data type

Example:

program Welcome;

uses

Wincrt;

var

a:integer;

b:integer;

c:integer;

begin

Writeln('Ente the three number: ');

Read(a);

Read(b);

Read(c);

Writeln('Answer is : ',a+b+c);

end.

Ouput:

How to work with the integer data type

How to work with the integer data type

To work with the integer data type

Description:

Type Range Format

Shortint -128..127 Signed 8-bit

Integer -32768..32767 Signed 16-bit

Longint -2147483648..2147483647 Signed 32-bit

Byte 0..255 Unsigned 8-bit

Word 0..65535 Unsigned 16-bit


How to work with readln example

How to work with readln example

To work with readln example

Example:

program Welcome;

uses

Wincrt;

var

a:string;

begin

Write('What is your name: ');

Readln(a);

Write('My nam is ',a);

end.

Output:

How to work with Readln function

How to work with Readln function

To work with Readln function

Description:

reads a file component into a variable

reads one or more values into one or more variables

Declaration:

Read(F , V1 [, V2,...,Vn ] )

How to work with Writeln or Write Example

How to work with Writeln or Write Example

To work with Writeln or Write Example

Example:

program Welcome;

uses

Wincrt;

begin

Write('Welcome to Pascal')

Writeln('Hello everybody');

Writeln('Please enter the number: ');

Writeln('Please enter the number: ');

Writeln('The answer is: ');

end.

Output:

How to work with Writeln or Write function

How to work with Writeln or Write function

To work with Writeln or Write function

Description:

This function is display the word in the screen.

Declaration:

Writeln('Hello everybody')