0% found this document useful (0 votes)
19 views3 pages

Basic Pascal Programming Examples

Uploaded by

sp6564arachchi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Basic Pascal Programming Examples

Uploaded by

sp6564arachchi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Pascal programming

Example 01 print “Basic Pascal” on screen.

Program _........................;
Begin
…………………………….
……………………………. Basic Pascal
End.

Example 02 Calculating Sum of given 2 numbers.


Program _..............................;
Var
………………………………..;
………………………………..;
Begin
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;

End.

Example 03 Calculating Average of given 2 numbers.

Program _..............................;
Var
………………………………..;
………………………………..;
Begin
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;
………………………………..;

End.

Example 04 write out put

Program _Output1;
Begin
Write(‘One :’); ……………………………………
Write(‘Two :’); ……………………………………
Writeln(‘Three :’ ……………………………………
Write(‘A :’); ……………………………………
Write(‘B :’); ……………………………………
Writeln(‘C :’); ……………………………………
Readln; ……………………………………
End.

Example 05 Print the message with first and Surname

program_ Greetings;
const
message = ' Welcome to the world of Pascal ';
type
name = ……………………….;
var
………………………………………;
begin
writeln(……………………………………….: ');
readln(f……………..);
writeln(…………………………………: ');
readln(………………);
writeln;
writeln(…………., ' ', …………….., ' ', …………………);
end.

Example 06 Finding Circumference Use const (PI = 3.141592654)

Program_Const circle;
……………………..
PI = 3.141592654;
………………………
r, d, c: ……………….;
Begin
writeln('Enter the radius of the circle');
readln(………..);
d := 2 * r;
c := PI * d;
writeln('The circumference of the circle is
',……………….);
End.

Example 07 -Operators

program ………………………..;
var
…………….. : integer;
…………….: real;
Begin
a:=21;
b:=10;
c := a + b;
writeln(' Line 1 - Value of c is ', ……… );
c := a - b;
writeln('Line 2 - Value of c is ', ……….. );
c := a * b;
writeln('Line 3 - Value of c is ', ………. );
d := a / b;
writeln('Line 4 - Value of d is ', ……… );
c := a mod b;
writeln('Line 5 - Value of c is ' , c );
c := a div b;
writeln('Line 6 - Value of c is ', c );
End.

Example 08 –Looping write output

Program WhileLoop; ……………………………………


Var ……………………………………
a:integer; ……………………………………
Begin ……………………………………
a:=10; ……………………………………
While ……………………………………
a<20 Do ……………………………………
Bigin ……………………………………
Writeln(‘Value of a: ’,a); ……………………………………
a-a+1; ……………………………………
end; ……………………………………
End.

Example 09 –Looping write output

program ForLoopExample;
var ……………………………………
i: integer; begin ……………………………………
for i := 1 to 5 do ……………………………………
begin ……………………………………
writeln('Current value of i: ', i); ……………………………………
end; ……………………………………
writeln('Loop finished.');
end.

You might also like