231867-06 B Pascal Arrays Function Prosidures and Paradime
231867-06 B Pascal Arrays Function Prosidures and Paradime
Array ^wrdj&
tl u m%rEmhg wh;a o;a; tl u kula fhdod .ksñka u;lh ;=< ;eïm;alÍ s ug wrdj Ndú; flf¾' tawkqj
lsishï fmdÿ kulska y÷kajk whs;u(Items) iuQyhla wrdjla(Array) f,i y÷kajkq ,nhs
(An array is used to save data items of the same type in memory using a single variable identifier name.)
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
O/L ICT ICT - A Wreufha woaú;Sh kduh - l=i,a weye,wdrÉÑ Page 1
yhjk jrg;a" ICT jxYl:dj rkska ,shQ" Y%S ,xldfõ wxl tfla" úch.%yS ICT mka;sh
ksiel A idud¾:h
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
/Array length = 5
taludk wrdj/One dimensional Array
wkql%ñl j ksYaÑ; m%udKhl tl u m%rEmhlg wh;a o;a; ;ekam;a lsÍu i|yd Ndú; lrk o;a; jHqyhls.
(This is a data structure used to save data of the same type sequentially)
taludk wrdjla ks¾udKh lsrSu (Creating an One dimensional Array)
Ex:-
VAR student : ARRAY(0..4) OF STRING;
VAR marks : ARRAY(0..9) OF INTEGER;
m%Yakh 01(-
Student keu;s úYd,;ajh 5 la jk wrdjla(Array) ks¾udKh lr tys uQ,dx.(Eliments) ;=< Samna, Kamal,
Nimal, Ruwan iy Sarath keu;s jpk .nvd lr kej; tajd fmkaùu'
Create an array of size of 5, named “Student” and store the words Saman, Kamal, Nimal, Ruwan and Sarath in
its elements and display those words and write a Pascal programme for above incident.
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
…………………………………………………………………………………………………………………….
m%Yakh 02(-
isiqka oifofkl=f.a jdr úNd.fha ICT <l=kq ,ndf.k “Thank You” hk mksúvh fmkaùfuka miqj kej;
tu ixLHd oyh ;srfha fmkaùug Pascal l%uf,aLh ,shkak'
Write a Pascal programme to get ICT marks of 10 students and show the message “Thank you” and display
those 10 marks.
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
……………………………………………………………………………………………………..
m%Yakh 03(-
isiqka oifofkl=f.a jdr úNd.fha ICT <l=kq ,ndf.k tajdfha tl;=j" idudkHh" jeäu <l=k iy wvqu
<l=k fidhd tajd fmkajk Pascal l%uf,aLhla wrdj(Array) wdOdrfhka ,shkak
Write a Pascal programme with the help of array to get ICT marks of 10 students and find the total marks,
average marks, maximum marks and minimum marks and show them.
PROGRAM ICT_Marks(INPUT,OUTPUT);
USES CRT;
VAR marks : ARRAY [0..9] OF INTEGER;
x,sum,max,min:INTEGER;
av:REAL;
BEGIN
CLRSCR;
max:=0;
min:=100;
FOR x:= 0 TO 9 DO
BEGIN
WRITELN(‘Enter ICT Marks’);
READLN(marks[x]);
sum:=sum+marks[x];
IF marks[x]>max THEN
max:=marks[x];
IF marks[x]<min THEN
min:=marks[x];
END;
CLRSCR;
av:=sum/10;
WRITELN(‘Total marks of all student ’,sum);
WRITELN(‘Average marks of a student’,av:2:2);
WRITELN(‘Maximum marks’,max);
WRITELN(‘Minimu marks’,min);
READLN;
END.
Wml%uf,aL (Sub Programme)
l%uf,aLhl l%shdj,s m%udKh jeäùu;a iu.u th ixlS¾K jk ksid lshjd f;areï .ekSu" l%uf,aLh kv;a;=
lsÍu jeks lghq;= wmyiq fõ' tneúka l%uf,aL ,sùfï § yels;dla ÿrg Wml%uf,aL f,i ,sùu isÿlrkq
,nhs'
As a program becomes complex, when the number of sub processes increase, it will be difficult to
read and understand and also to maintain. Therefore, programs as much as possible while writing
is useful.
O/L ICT ICT - A Wreufha woaú;Sh kduh - l=i,a weye,wdrÉÑ Page 4
yhjk jrg;a" ICT jxYl:dj rkska ,shQ" Y%S ,xldfõ wxl tfla" úch.%yS ICT mka;sh
ksiel A idud¾:h
Wm .eg¿j 01 Wm l%uf,aLh 01
Sub problem Sub programme 01
01 ………………..
Wm .eg¿j n Wm l%uf,aLh n
Sub problem n Sub programme n
………………..
m%Odk l%uf,aLh yd iïnkaO Wml%uf,aL u.ska m%Odk l%uf,aLh fj; m%;sodkhla wdmiq ,nd §ug yels iy
fkdyels jYfhka Wml%uf,aL j¾. folla we;' m%;o s dkhla wdmiq ,nd Èh yels Wml%uf,aL Y%s; ^Function&
f,i o" m%;o s dkhla wdmiq ,nd Èh fkdyels Wml%uf,aL ld¾h mámdáh ^Procedure& f,i o ye¢kafõ'
(There are two types of sub programs in addition to the main program. A sub program which returns an output
back to the main program and a sub program which does not return an output back to the main program. A sub
program which returns an output back is called a Function and a sub program which does not give an output is
called a Procedure.)
PROGRAM
CONST
VAR
Wml%uf,aLh/Sub programme
BEGIN
m%Odk l%uf,aLh ;=,oS Wm l%uf,aLh weu;Su
Calling the sub programme
END.
BEGIN
ld¾h mámdáfha wvx.= m%ldYk 1/Statement 1;
ld¾h mámdáfha wvx.= m%ldYk 2/Statement 2;
:
ld¾h mámdáfha wvx.= m%ldYk n/Statement n;
END;
Y%s;h ^Function&
FUNCTION Y%s;fha ku (VAR úp,H ( o;a; m%rEmh ):Y%s;fha o;a; m%rEmh/DATA TYPE of function ;
BEGIN
Y%s;fha wvx.= m%ldYk 1/Statement 1;
Y%s;fha wvx.= m%ldYk 2/Statement 2;
:
Y%s;fha wvx.= m%ldYk n/Statement n;
END ;
m%Yakh 01(-
jD;hl wrh ,ndf.k j.–M,h fidhd th fmkajk Pascal l%uf,aLkh ,shkak
Write a Pascal programme that shows the Area when the Radius of a circle is given
PROGRAM Circle(INPUT,OUTPUT);
USES CRT;
CONST pie:=22/7;
VAR r:INTEGER;
cho:STRING;
BEGIN
TEXTCOLOR(YELLOW);
REPEAT
get_data(r);
area(r);
WRITELN(‘Do you want to run this again? For YES press Y and NO press N’);
READLN(cho);
UNTIL((cho <> ‘y’) AND (cho <> ‘Y’));
END.
PROGRAM Circle(INPUT,OUTPUT);
USES CRT;
CONST pie:=22/7;
VAR r:INTEGER;
úOdkd;aul m%ldYk
(Imperative) (Declarative)
mrsYS,lhdg o;a; we;=,;a lrk f,i oekqï fohs/ (Informs the user to enter data)
mrsYS,lhd we;=,;a l< o;a; ,nd.kS/ (Retrieves data entered by the user)
o;a; l%h
s dj,shg Ndckh lrhs (Data is processed)
jia;= keUqre mß.Kl l%uf,aL hkq jia;= (Objects) hk ixl,amh u; mokï jQ l%uf,aL mervhsu fõ'
(Object oriented programming is a programming paradigm based on the concept of objects.)
l%uf,aLk NdIdj, idudkHfhka mo fhdackh (Syntax) iïnkaOfhka ±ä kS;s Í;s mj;S' ks;r u mdfya
iïmdokh lsÍu wjYH fõ' l%uf,aL NdId iïmdokh (Compile) l< hq;= fõ. msgm;a f,aLk NdId
idudkHfhka fjk;a fhojqula
^WÞ - fjí n%jqirhla fyda fjí i¾jrhla& iu. fndfyda úg l%h s d;aul jk fla;hla ksIm
a dokh flf¾'
tfuka u msgm;a f,aLk NdId w¾: úkHdY (Interprit) l< hq;= h' kjlhkaf.ka w;sYh nyq;rhla msgm;a
rpk NdIdj Ndú; lsÍu jvd myiq hehs is;;s'
(Usually, there are hard and fast syntax rules in programming languages. These should often be compiled.
Programming languages need to be compiled. Further, scripting languages should be interpreted.)
www.apexonline.lk (0702229555)
m<uq lKavdhu
foie' 02 n%yiam;skaod iji 5'00-07'00
fojk lKavdhu
foie' 04 fikiqrdod rd;%S 8'30 - 10'30
f;jk lKavdhu
foie' 05 brsod rd;%S 8'30 - 10'30
-------------------------------------------------------------
www.surathaonline.lk (0412233169)
m<uq lKavdhu
foie' 01 nodod iji 05'00 - 07'00
fojk lKavdhu
foie' 06 i÷od rd;%S 8'30 - 10'30
-------------------------------------------------------------
www.dakunaonline.com (0779143001)
m<uq lKavdhu
foie' 04 fikiqrdod iji 05'00 - 07'00
fojk lKavdhu
foie' 05 brsod iji 03'30 - 05'30
jeo.;a(-
by; Online ICT mka;s 2023 i'fm< úNd.h olajd
wLKavj l%shd;aul fõ'