You are on page 1of 2

PASCAL PROGRAMMING write command is used to display something on

meial,a l%uf,aLKh the screen


;srh u; hula fmkaùu i|yd write fla;h
Programming is the art of teaching a computer Ndú;d lrhs
how to do something
hï l%shdjla isÿ lrkafka flfiaoehs Spaces can be kept inside the quotes
mß.Klhlg b.ekaùfï l,dj l%uf,aLKhhs WoD; mdG ;=, ysia;eka ;eìh yel

writeln is used to come to a new line after


displaying something
Displaying a string hula fmkajQ miq w¿;a fma,shlg meñkSu i|yd
;srh u; string tlla fmkaùu writeln Ndú;d lrhs

a string is a sequence of characters


string tlla hkq characters lsym s hl tl;=jls
it may include letters of any language, digits, and readln ;
any other special characters
tys ´kEu NdYdjl wl=re" b,lalï iy fjk;a A program is kept waiting without terminating
´kEu úfYaI wkq,laYKhla mej;sh yel until we press the enter key after execution is
completed
write ( ‘ helloworld ’ ) ;
l%shd;aul ùu wjika jQ miq enter h;=r Tnk
f;la jevigyk ;jÿrg;a ;srfha r|jd
In Pascal, every command line must end with a ;nd.kS
semicolon ; It informs the computer that one
instruction is over and a new instruction is going
to begin Indicating comments
meial,ay§ s iEu fla; fma,shlau ;s;a újrK fh§u
fldudjlska wjika úh hq;=h' tla Wmfoila
wjika nj;a wÆ;a Wmfoila wdrïN ùug hk Comments are pieces of the code which are
nj;a tu.ska mß.Klhg oekqïfoa'
completely discarded by the compiler.
write ( ‘ hello ’ ) ; újrK hkq iïmdolh úiska iïmQ¾Kfhka u
fkdi,ldyßk fla; fldgiah
write ( ‘ hello ’ ) ;
write ( ‘ hello ’ ) ;
Comments are three types
újrK wdldr ;=klska mj;S
Keeping spaces
Multi line comments
mr;r ;eîu
1. { content }
2. (* content *)
write ( ‘hello world’ ) ;
Single line comments
write ( ‘hello world’) ;
3. // content
Going to a new line:
w¿;a fma,shlg .uka lsÍu comments are used
újrK Ndú;d jkqfha
writeln ( ‘ hello ’ ) ;
• to improve self-readability of the code
write ( ‘ hello ’ ) ;
fla;hl iajhx-lshùfï yelshdj j¾Okh
lsÍu i|yd
writeln ( ‘ hello ’ ) ; • for the easy reference of third parties
writeln ( ‘ hello ’ ) ; ;=kja k md¾Yjhl myiq wOHkh i|yd
• to temporarily neglect code sectors
fla; fldgia ;djld,slj fkdi,ldyeÍu
i|yd
Mathematical operators scientific notation & formatted output
.Ks;uh fufyhjk úoHd;aul wxlk yd m%;sodk wdlD;SlrK

write ( 5 / 2 ) ;
Addition result on the screen will be 2.5000E + 000
+ 5+2
tl;=lsÍu ;srh u; Èiajk m%;sodkh 2.5000E + 000
Subtraction
- 5-2
wvqlsÍu
Multiplication write ( 0.5 / 2 ) ;
* 5*2
.=KlsÍu
write ( 5 / 2 ) ;
Normal division
/ 5/2 write ( 50 / 2 ) ;
idudkH fn§u
Integer division write ( 500 / 2 ) ;
DIV 5 DIV 2
ksÅ, fn§u
Modulus division
MOD 5 MOD 2
b;sß fn§u

Calculations with the write command


write fla;h iu. .Kkh lsÍï
Mathematical operator precedence
.Ks;uh fufyhjk m%uqL;d wkqms<sfj, write ( ‘ 2 + 5 ’ ) ;
content is displayed - wka;¾.;h fmkajhs
the order in which operators are evaluated in an
expression containing more than one operator is write ( 2 + 5 ) ;
the operator precedence calculated value is displayed
fufyhjk tllg jvd jeä .Kkla iys; .Kkh lrk ,o w.h fmkajhs
m%ldYKhl tajd we.hSug ,la l, hq;= ms,sfj,
fufyhjk m%uqL;d wkqms,sfj, h write ( ‘ 2 + 5 = ’ , 2 + 5 ) ;
same write command can be used to show
Parentheses are used to change the normal
several arguments on the screen at once
operator precedence
idudkH fufyhjk m%uqL;d wkqms,sfj, fjkia ;srh u; arguments lsym s hla fmkaùu i|yd
lsÍug jryka Ndú;d lrhs tlu write fla;h Ndú;d l, yel

therefore it has the maximum priority


tuksid thg jeäu m%uqL;djh mj;S

Parentheses jryka ()
Division fn§u / Prepared by:
DIV
MOD Ravindu Bandaranayake
Maliyadeva College (Batch 2014 - Science)
Multiplication .=KlsÍu * B.Sc. Cyber Security (Undergraduate)
Addition tl;=lsÍu + BCS Level 5
Subtraction wvqlsÍu - Dropout – SLIIT (Software Engineering)
Dropout – Wayamba University of Sri Lanka
(Applied Sciences)
When the same operator is repeatedly present in
an expression, those operators are executed
from left to right ict from abc
m%ldYKhla ;=, tlu fufyhjkh kej; ,xldfõ úYd,;u Online ICT mka;sh
kej; fhfok úg tu fufyhjk jfï isg
ol=Kg l%shd;aul lrjhs visit https://ictfromabc.com to register
call 0714 555513 for more info

You might also like