O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
OBJEKTIVAT
1) Te klasifikojne gjuhet e programimit
2) Te perdorin editorin e Pasklit, Turbo Paskal 7.
3) Te perdorin sinta...
8) Te perdorin instruksionin If.
9) Te perdorin instruksionin If..Then..Else.

10) Te realizojne komente ne Paskal.
11) Te...
Çfare do te trajtohet ne kete kapitull
1.Çfare eshte gjuha Pascal
2.Klasifikimi I gjuheve te programimit
3.Editori I gjuhe...
HAPAT QE KALON NJE GJUHE PROGRAMIMI

1. Percaktimi I problemit
2. Zhvillimi I algoritmit
3. Ndertimi I programit
4. Testim...
Klasifikimi I gjuheve te programimit
1.Gjuha
2.Gjuha
3.Gjuha
4.Gjuha

e makines
ansembler
e nivelit te larte
e gjenerates ...
U krijua nё vitet 1968 – 1969 nga Niklaus
Wirth.
E merr emrin nga matematicieni francez Blaise
Pascal
STRUKTURA E GJUHES PASCAL

{Instruksionet fakultative per kompilimin e programit}
Program {emri I programit}
Uses {perdoru...
program emri_mbiemri;
uses crt;
var emri : string;
begin
writeLn(‘shkruaj emrin tend ’);
readLn(emri);
writeLn(‘emri juaj ...
Algoritmi I mesiperm I shkruar ne gjuhen Pascal

Program usht;
Uses crt;
Var a,b,x :real;
Begin
Writeln(‘vendosni vlerat e...
•
•
•
•
•
•
•
•
•
•
•

Tipet e variablave.

Shortint : vendos nje numer nga -127 ne 128
Byte : vendos nje vlere nga 0 ne 2...
Disa nga funksionet numerike te gateshe te gjuhes Pascal
Funksioni Sqarim
Abs(x)

Gjen vleren absolute te arg. x

Tipi I
T...
Shembuj
Funksioni

Rezultati

Abs(-3.5)

3.5

Abs(-7)
Cos(0)

7
1

Ln(1)
Odd(3)
Odd(-4)

0
True
False

Round(1.7)
Trunc(1....
Fjale te rezervuara ne gjuhen Pascal
AND, ARRAY, ASM, BEGIN, CASE, CONST,
CONSTRUCTOR, DESTRUCTOR,
DIV, DO, DOWNTO, ELSE, ...
Model ushtrimi ne Pascal

Program sip;
{emri I programit}
Uses crt;
{mjedisi qe do te perdoret per perfundimin ose librari...
Rregulla te pergjithshme per gjuhen Pascal
1. Çdo instruksion mbyllet me pikpresje
2. Begin nuk mbyllet me pikpresje
3. En...
TIPET E VARIABLAVE NUMERIKE DHE HAPESIRAT QE ATO ZENE

1. Variabli I tipit Integer (I plote) ruhet secila ne 2 bajte
2. Va...
INSTRUKSIONE TE NDRYSHME
1. Instruksioni I vleredhenies sintaksa eshte
<emer> := <shprehje>
shembull
p := (a+b+c)/2;
siper...
4. Instruksioni Write kryen paraqitjen e vlerave te ndryshoreve
ne ekran. Ai shkruhet ne trajten Write(<liste>);
shembull
...
SHEMBUJ TE NDRYSHEM PER PERDORIMIN E KETYRE INSTRUKSIONEVE
Clrscr=> clirscrin, pastro ekranin
Program Shtyp;
Uses Crt;
Con...
Program Shtyp;
Uses Crt;
Var d : Integer;
Begin
ClrScr;
d:=26;
Write('Shpejtesia: ',d);
ReadLn;
End.

Program Shtyp;
Uses ...
Program Shtyp;
Uses Crt;
Const
a = 5;
b = 9;
Begin
ClrScr;
Write('Lartesia: ',a+2*b);
ReadLn;
End.

Program Shtyp;
Uses Cr...
Program Test;
Var x,y,z : Real;
Begin
x:=-98.74;
y:=-23.6;
z:=459.875;
WriteLn(x:8);
WriteLn(x:10);
WriteLn(x:14);
WriteLn...
Program Shtyp_10;
Uses Crt;
Const t = 125;
Var d : Integer;
Begin
ClrScr;
d:=44;
Write('Koha t=',t,' Vonesa d=',d);
ReadLn...
Program Shtyp;
Uses Crt;
Const x = 'Siperfaqja ....: ';
y = 'Perimetri .......: ';
Var a,b,s,p : Real;
Begin
ClrScr;
TextC...
Program Shtyp;
Uses Crt;
Const n = 6;
Var A : Array[1..n] Of Integer;
i,j,s : Integer;
Begin
ClrScr;
WriteLn('Vektori A');...
INSTRUKSIONI I DEGEZIMIT
If<kusht logjik> Then<instruksion>;
If x>0 Then Writeln (‘x eshte numer pozitiv’);

If (x>0) And ...
Program koordinatat;
Uses crt;
Var x,y : real;
Begin
Writeln(‘jepni koordinatat e pikes’);
Readln(x,y);
If (x>0) and (y>0)...
INSTRUKSIONI For … To … Do
Program TextBg;
Uses Crt;
Var i : Integer;
Begin
ClrScr;
For i:=0 To 7 Do
Begin
TextBackground(...
Program Shtyp;
Uses Crt;
Const a = 8;
b = 4;
r = '------------------------';
g=' i
2*i+3
3*i-a
y';
Var i : Integer; y : Bo...
PROGRAM llogarit;
VAR vle1, vle2, rezultat : real;
operator : char;
BEGIN
writeln(‘Vlera e pare ?');
readln(vle1);
writeln...
Program shembull;
Const
t = 'Lapsi e Libri';
Var
x,y : String[15];
i,a : Integer;
Begin
a:=Length(t);
For i:=1 To a Do
Beg...
Program shembull;
Uses Crt;
Var i : Integer;
Const bornesup = 10000 ;
BEGIN
i := 0;
repeat
WriteLn(sqrt(i));
Inc(i);
until...
Program shembull3;
Var Numer : Integer;
Begin
Write(‘Shkruani nje numer jo me te madh se njeqind : ');
Readln(Numer) ;
if ...
Program shembull4;
Var i : Integer;
Begin
Randomize;
i := random(100);
if i < 50 then WriteLn ( i, ' eshte me i vogel se 5...
Shembull per te perdorur instruksionin case …. of

Program shembull5;
Var mosha : Integer;
Begin
Write(‘Shkruani moshen tu...
Shembull per te perdorur instruksionin For ….. Downto ….
Dhe repeat…….until

Program shembull8;
Uses crt;
Var i : Integer;...
Program Exemple9b;
Uses Crt;
Procedure Maths (Param : Real);
Begin
WriteLn('Procédure de calcul. Veuillez patienter.');
Pa...
Program shembull9;
Uses Crt;
Procedure madhesia(var emri: String);
Begin
Write(‘vendosni emrin tuaj : ');
ReadLn(emri);
En...
Program shembull10;
Uses Crt;
Function fuqia(i, j : Integer) : Integer;
Var Rez, a : Integer ;
Begin
Rez := 1;
for a := 1 ...
Shembull per te perdorur instruksionin sound per efekte zanore

Program shembull12;
Uses Crt;
Var i, f : Integer;
BEGIN
fo...
Shembull per perdorimin e variablit string dhe byte

Program shembull24;
Type varg = String[20];
Var
emer : varg;
mosha : ...
Program shembull14;
Var
emer : String;
BEGIN
emer:= ‘magdalena';
emer[2] := 'Z';
emer[0] := Chr(4);
WriteLn(emer);
emer[0]...
Program shtyp;
Var i, x : Integer;
Begin
x := 0 ;
Repeat
Inc(i);
Break;
x := 50;
until i > 10;
WriteLn(i);
WriteLn(x);
End...
Program Exemple19;
Uses
Dos;
Var
i : Integer;
BEGIN
for i := 1 to EnvCount do WriteLn(EnvStr(i));
END
Shembull per te lexuar hapesiren e lire te harddiskut ne bajt

Progaram disk;
Uses Dos;
Var L : LongInt;
Begin
L := diskfr...
Program funksioni;
Uses crt;
Var x,y : real;
Begin
Clrscr;
Write(‘vlera e ndryshores x=‘);
Readln(x);
If x<9 then y:=sqr(x...
program dallor;
uses crt;
var a,b,c,x1,x2,d,x : real;
begin
writeln('Jepni vleren e a,b,c te trinomit, a!=0');
readln(a,b,...
writeln('ekuacioni ka dy rrenje te bara. x1=x2=', x:4:2);
end
else if d > 0 then
begin
x1 := (-b+sqrt(d))/(2*a);
x2 := (-b...
Program for;
Uses crt;
Var x,y :char;
Begin
Clrscr;
Randomize;
For x:=‘Z’ downto ‘A’ do
Begin
For y:=‘A’ to x do
begin
Tex...
Program çift_ose_tek;
Uses crt;
Var
n : integer;
tek : boolean;
Begin
Clrscr;
Write(‘Vendosni nje numer te plote n=‘);
Rea...
Program faktorial;
Uses crt;
Var n,i : integer;
F : real;
Begin
Clrscr;
Write(‘Vlera e n eshte n=‘);
Readln(n);
F :=1;
i:=...
Program shuma_çift;
Uses crt;
Const n = 14;
s : longint = 0;
i : integer = 0;
Begin
Clrscr;
Repeat
S :=s+i;
i :=i+2;
Until...
Program pjestuesi;
Uses crt;
Const v =‘______________________________________’;
Var i,k : integer;
Begin
Clrscr;
Write(‘pj...
Program perserit;
Uses crt;
Var p : char;
Begin
Clrscr;
Repeat
Writeln(^G); {Krijon hapesire nga rreshti dhe vendos nje sh...
program ushtrim7;
uses crt;
var i : integer;
begin
clrscr;
i :=0;
while i <18 do
begin
inc (i);
if i <10 then continue;
wr...
Perdorimi I tabelave

Program a;
Const
m = 8;
x : Array[1..m] of Integer = (5,-7,8,4,-2,9,3,-1);
Var i,s : Integer;
Begin
...
Program dritare;
Perdorimi instruksionit
Uses Crt;
Window dhe textcolor
Var c : Byte;
Begin
Randomize;
c:=Random(5);
TextB...
Program koordinata;
Perdorimi i instruksionit
Uses Crt;
GoTo dhe instruksionit
Var i : Integer;
cLreoL
Begin;
ClrScr;
For ...
Program e_enjte;
Program per
Uses Crt;
Perdorimin e instruksionit
Var i: Byte;
DeLLine dhe Delay
Begin
ClrScr;
For i:=1 To...
Program Dita;
Const
Pi=3.1415926;
a='Rrezja e rrethit: ';
b='Siperfaqja s=';
c='Perimetri p=';
Var
r,s,p: Real;
Begin
Writ...
Program Dita;
Uses Crt;
Const k = 'A';
Var
i,n : Char;
Begin
ClrScr;
Randomize;
Write(‘Vendosni nje shkronje: ');
ReadLn(n...
Gjetja e elementeve
negative te nje bashkesie
Program tabela;
Uses Crt;
Const
m = 5;
A : Array[1..m] Of Integer = (3,-2,7,...
Gjetja e elementeve pozitive
dhe negative te nje bashkesie
Program tabela;
Uses Crt;
Const
m = 5;
A : Array[1..m] Of Integ...
Gjetja e vleres maximale per variablin e tipit
integer dhe longinteger

Program Dita;
Var
a : Integer;
b : LongInt;
Begin
...
Menyre tjeter per gjetjen e sip. dhe perimetrit te rrethit
Program 3;
Const Pi=3.1415926;
a='Rrezja e rrethit: ';
b='Sip‰r...
Program per te treguar oren e kompjuterit
Keypressed=>shtyp nje tast
Program GetTime;
per te ndaluar
Uses Dos,Crt;
Var
Ora...
Gjuha paskal
Gjuha paskal
Gjuha paskal
Próximos SlideShares
Carregando em…5
×

Gjuha paskal

1.832 visualizações

Publicada em

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Gjuha paskal

  1. 1. OBJEKTIVAT 1) Te klasifikojne gjuhet e programimit 2) Te perdorin editorin e Pasklit, Turbo Paskal 7. 3) Te perdorin sintaksen e gjuhes Paskal. 4) Te percaktojne tipin e variablave 5) Te ndertojne nje variabel 6) Te perdorin funksionet numerike te gjuhes Paskal. 7) Te perdorin instruksionet Read, Write, Readln, Writeln.
  2. 2. 8) Te perdorin instruksionin If. 9) Te perdorin instruksionin If..Then..Else. 10) Te realizojne komente ne Paskal. 11) Te realizojne formatimin e perfundimit. 12) Te perdorin instruksionet While, Repeat. 13) Te perdorin madhesite String
  3. 3. Çfare do te trajtohet ne kete kapitull 1.Çfare eshte gjuha Pascal 2.Klasifikimi I gjuheve te programimit 3.Editori I gjuhes Pascal 4.Tipet e ndryshoreve 5.Instruksioni I vlerdhenies 6.Instruksionet Read,Write,Readln,Writeln 7.Trajtimi I madhesive string
  4. 4. HAPAT QE KALON NJE GJUHE PROGRAMIMI 1. Percaktimi I problemit 2. Zhvillimi I algoritmit 3. Ndertimi I programit 4. Testimi I programit 5. Pergatitja e dokumentit
  5. 5. Klasifikimi I gjuheve te programimit 1.Gjuha 2.Gjuha 3.Gjuha 4.Gjuha e makines ansembler e nivelit te larte e gjenerates se katert
  6. 6. U krijua nё vitet 1968 – 1969 nga Niklaus Wirth. E merr emrin nga matematicieni francez Blaise Pascal
  7. 7. STRUKTURA E GJUHES PASCAL {Instruksionet fakultative per kompilimin e programit} Program {emri I programit} Uses {perdoruesi I programit} Const {deklarimi I konstanteve} Funksionet {deklarimi I funksioneve} Var {deklarimi I variablave} {instruksione te detyruara} Begin {programi kryesor} …. Komanda … End. {mbyllja e programit}
  8. 8. program emri_mbiemri; uses crt; var emri : string; begin writeLn(‘shkruaj emrin tend ’); readLn(emri); writeLn(‘emri juaj eshte’, emri); readLn; end.
  9. 9. Algoritmi I mesiperm I shkruar ne gjuhen Pascal Program usht; Uses crt; Var a,b,x :real; Begin Writeln(‘vendosni vlerat e a,b’); Readln(a,b); x:=-b/a; Writeln(‘rezultati eshte x=‘,x); Readln; End.
  10. 10. • • • • • • • • • • • Tipet e variablave. Shortint : vendos nje numer nga -127 ne 128 Byte : vendos nje vlere nga 0 ne 255 byte Integer : vendos nje vlere nga -32 768 ne 32 767 Word : vendos nje vlere nga 0 ne 65535 Longint : vendos nje vlere nga – 2 147 483 648 ne 2 147 483 647 Real : vendos nje numer real nga 2,9E10-39 ne 1,7E1038 me 11 shifra Double : vendos nje vlere reale nga 5,0E10-324 ne 1,7E10 +308 me 15 shifra Extended : vendos nje vlere reale nga 1,9E10-4951 ne 1,1E10-4932 Char : nje karakter alfanumerik String : fjali deri ne 256 karaktere. Boolean : vlere logjike TRUE ose FALSE
  11. 11. Disa nga funksionet numerike te gateshe te gjuhes Pascal Funksioni Sqarim Abs(x) Gjen vleren absolute te arg. x Tipi I Tipi I rezultatit argumentit Real ose Integer Si I argumentit x Cos(x) Gjen cosinusin e kendit x (radian) Real ose Integer Real Sin(x) Gjen sinusin e kendit x (ne radian) Real ose Integer Real Exp(x) Gjen ex, ku e=2.71828… Real ose Integer Real Ln(x) Gjen lnx, x>0 Real ose Integer Real Odd(n) Merr vleren True kur n Integer eshte numer tek dhe vleren False ne rast te kundert Boolean Round(x) Rrumbullakos numrin x, Real pra gjen vleren e plote me te afert me x Integer Sqrt(x) Gjen rrenjen katerore te x Real ose Integer Real Trunc(x) Gjen pjesen e plote te x Real Integer Frac(x) Gjen pjesen dhjetore te x Real Real Int(x) Gjen pjesen e plote te x Real Real
  12. 12. Shembuj Funksioni Rezultati Abs(-3.5) 3.5 Abs(-7) Cos(0) 7 1 Ln(1) Odd(3) Odd(-4) 0 True False Round(1.7) Trunc(1.7) 2 1 Frac(1.7) 0.7 Int(1.7) 1.0
  13. 13. Fjale te rezervuara ne gjuhen Pascal AND, ARRAY, ASM, BEGIN, CASE, CONST, CONSTRUCTOR, DESTRUCTOR, DIV, DO, DOWNTO, ELSE, END, EXPORTS, FILE, FOR, FUNCTION,GOTO, IF, IMPLEMENTA TION, IN, INHERITED, INLINE, INTERFACE,LAB EL, LIBRARY, MOD, NIL, NOT, OBJECT, OF, OR, PACKED,PROCEDURE, PROG RAM, RECORD, REPEAT, SET, SHL, SHR, STRIN G,THEN, TO, TYPE, UNIT, UNTIL, USES, VAR, WHILE, WITH, XOR.
  14. 14. Model ushtrimi ne Pascal Program sip; {emri I programit} Uses crt; {mjedisi qe do te perdoret per perfundimin ose libraria} Const a = 4; {konstantet qe percaktohen nga ne} b = 4; Var c,s,p : real; {variablat dhe tipi I tyre} Begin {fillimi I trupit te programit} s := (a*b)/2; writeln(‘siperfaqja……s=‘,s:2:2); {Writeln paraqet ç’ka eshte c:=sqrt(a*a+b*b); shkruar ne thonjeza teke writeln(‘brinja…………c=‘,c:6:2); dhe s:2:2 kemi bere p:=a+b+c; formatimin e perfundimit} writeln(‘perimetri…….p=‘,p:6:2); readln; {readln lexon nje rresht te tere} End. {mbyllja e programit}
  15. 15. Rregulla te pergjithshme per gjuhen Pascal 1. Çdo instruksion mbyllet me pikpresje 2. Begin nuk mbyllet me pikpresje 3. End mbyllet me pike 4. Komentet ne Pascal vendosen ne kllapa { } ose(* *) 5. Ruajtja e doc. Behet me prapashtesen .pas qe vendoset ne menyre automatike nga editori
  16. 16. TIPET E VARIABLAVE NUMERIKE DHE HAPESIRAT QE ATO ZENE 1. Variabli I tipit Integer (I plote) ruhet secila ne 2 bajte 2. Variabli I tipit Real ruhet secila ne 6 bajte 3. Variabli I tipit logjik merr vetem True ose False rrjedhimisht ruhet ne 1 bajte. 4. Variabli I tipit string (varg) merr vlera deri ne 256 karaktere rrjedhimisht per cdo karakter llogaritet 1 bajte, pra gjithsej 256 bajte. 5. Variabli I tipit Char (character) shprehet vetem me nje karakter, rrjedhimisht hapesira qe ze eshte 1 bajte. 6. Variablat mund te krijohen dhe vete por duhet te plotesojne disa kushte. = Te perdorim vetem shkronja dhe numra dhe jo shenja te veçanta = Te filloje me shkronje dhe jo me numer.
  17. 17. INSTRUKSIONE TE NDRYSHME 1. Instruksioni I vleredhenies sintaksa eshte <emer> := <shprehje> shembull p := (a+b+c)/2; siperfaqja := sqrt(p*(p-a)*(p-b)*(p-c)); 2. Instruksioni Read u jep ndryshoreve vlera drejtperdrejte nga tastiera. Ky instruksion zbatohet ne trajten Read(<liste ndryshoresh>); p.sh Read(a,b,c); 3. Instruksioni Readln lexon nje rresht te tere. Paraqitja e tij eshte Readln(<liste ndryshoresh>);p.sh Readln(a,b,c);
  18. 18. 4. Instruksioni Write kryen paraqitjen e vlerave te ndryshoreve ne ekran. Ai shkruhet ne trajten Write(<liste>); shembull Write(4*5 Div 2); do te paraqese ne ekran vleren 10. 5. Instruksioni WriteLn paraqet ne ekran vlerat e madhesive, qe figurojne ne liste, duke filluar ne rresht te ri. Paraqitja behet ne trajten WriteLn(<liste>);
  19. 19. SHEMBUJ TE NDRYSHEM PER PERDORIMIN E KETYRE INSTRUKSIONEVE Clrscr=> clirscrin, pastro ekranin Program Shtyp; Uses Crt; Const x = 'Dita'; y = 'Nata'; Var g : Char; Begin ClrScr; g:='e'; Write(y,g,x); ReadLn; End. Program usht4; Uses Crt; Const x = 'Dita'; y = 'Nata'; Var g : Char; Begin ClrScr; g:='e'; Write(y); Write(' ',g,' '); Write(x); ReadLn; End.
  20. 20. Program Shtyp; Uses Crt; Var d : Integer; Begin ClrScr; d:=26; Write('Shpejtesia: ',d); ReadLn; End. Program Shtyp; Uses Crt; Var a,b : Integer; Begin ClrScr; a:=387; b:=-45; Write(a,b); ReadLn; End.
  21. 21. Program Shtyp; Uses Crt; Const a = 5; b = 9; Begin ClrScr; Write('Lartesia: ',a+2*b); ReadLn; End. Program Shtyp; Uses Crt; Const a = 5; b = 9; Var y : Integer; Begin ClrScr; y:=a+2*b; Write('Lartesia: ',y); ReadLn; End.
  22. 22. Program Test; Var x,y,z : Real; Begin x:=-98.74; y:=-23.6; z:=459.875; WriteLn(x:8); WriteLn(x:10); WriteLn(x:14); WriteLn(x:8:2); WriteLn(x:20); WriteLn(y:7:1); WriteLn(z:8:3); WriteLn(y:7:4); WriteLn(z:2:3); WriteLn(z:8:1); ReadLn; End. SHEMBULL PER TE KRYER FORMATIMIN E PERFUNDIMIT
  23. 23. Program Shtyp_10; Uses Crt; Const t = 125; Var d : Integer; Begin ClrScr; d:=44; Write('Koha t=',t,' Vonesa d=',d); ReadLn; End.
  24. 24. Program Shtyp; Uses Crt; Const x = 'Siperfaqja ....: '; y = 'Perimetri .......: '; Var a,b,s,p : Real; Begin ClrScr; TextColor(Green); Write('Brinjet a dhe b: '); TextColor(Red); ReadLn(a,b); TextColor(LightBlue); Write(x); s:=a*b; TextColor(Cyan); WriteLn(s:0:2); TextColor(Yellow); Write(y); p:=2*(a+b); TextColor(LightRed); Write(p:0:2); ReadLn; End.
  25. 25. Program Shtyp; Uses Crt; Const n = 6; Var A : Array[1..n] Of Integer; i,j,s : Integer; Begin ClrScr; WriteLn('Vektori A'); WriteLn; For i:=1 To n Do Begin s:=0; For j:=1 To i Do s:=s+Sqr(j); A[i]:=s; Write(A[i]:3) End; ReadLn End.
  26. 26. INSTRUKSIONI I DEGEZIMIT If<kusht logjik> Then<instruksion>; If x>0 Then Writeln (‘x eshte numer pozitiv’); If (x>0) And (y>0) Then Writeln(‘x dhe y jane pozitiv’);
  27. 27. Program koordinatat; Uses crt; Var x,y : real; Begin Writeln(‘jepni koordinatat e pikes’); Readln(x,y); If (x>0) and (y>0) then Writeln(‘pika gjendet ne kuadratin e If (x<0) and (y>0) then Writeln(‘pika gjendet ne kuadratin e If (x<0) and (y<0) then Writeln(‘pika gjendet ne kuadratin e If (x>0) and (y<0) then Writeln(‘pika gjendet ne kuadratin e Readln; End. pare’) else dyte’) else trete’) else katert’) ;
  28. 28. INSTRUKSIONI For … To … Do Program TextBg; Uses Crt; Var i : Integer; Begin ClrScr; For i:=0 To 7 Do Begin TextBackground(i); TextColor(i+7); WriteLn(' Ngjyra e prapavijes eshte: ',i,' '); End; ReadLn; End.
  29. 29. Program Shtyp; Uses Crt; Const a = 8; b = 4; r = '------------------------'; g=' i 2*i+3 3*i-a y'; Var i : Integer; y : Boolean; Begin ClrScr; WriteLn(g); WriteLn(r); For i:=-2 To 10 Do Begin y:=((2*i+3) <= (3*i-a)) Or ((i+1) > b); WriteLn(i:3,(2*i+3):6,(3*i-a):6,y:8); End; Write(r); ReadLn; End.
  30. 30. PROGRAM llogarit; VAR vle1, vle2, rezultat : real; operator : char; BEGIN writeln(‘Vlera e pare ?'); readln(vle1); writeln(‘operator (+ - * /) ? '); readln(operator); writeln(‘Vlera e dyte ? '); readln(vle2); case operator of '+' : rezultat := vle1 + vle2; '-' : rezultat := vle1 - vle2; '*' : rezultat := vle1 * vle2; '/' : rezultat := vle1 / vle2; end; writeln(‘rezultat : ',rezultat); Readln; END. Instruksioni case … of shembull
  31. 31. Program shembull; Const t = 'Lapsi e Libri'; Var x,y : String[15]; i,a : Integer; Begin a:=Length(t); For i:=1 To a Do Begin x:=t; Delete(x,1,a-i); y:=x; WriteLn(i:2,y:a+1); End; ReadLn; End. Program shembull; Var emer : String; BEGIN Write(‘Shkruani emrin tuaj : '); ReadLn(emer); WriteLn(‘emri juaj eshte ', emer); ReadLn; END.
  32. 32. Program shembull; Uses Crt; Var i : Integer; Const bornesup = 10000 ; BEGIN i := 0; repeat WriteLn(sqrt(i)); Inc(i); until (i = bornesup) or KeyPressed; END. Program shembull2; Var Numer: Integer; Begin Write(‘Vendosni nje numer jo shume te madh: '); Readln(Numer); if Numer< 100 then WriteLn(Numer, ' eshte me i vogel se njeqind.') else WriteLn(Numer, ' eshte me i madh ose i barabarte se njeqind.'); End.
  33. 33. Program shembull3; Var Numer : Integer; Begin Write(‘Shkruani nje numer jo me te madh se njeqind : '); Readln(Numer) ; if Numer < 100 then begin WriteLn(Numer, ' eshte me i vogel se njeqind.'); end else begin WriteLn(Numer, ' eshte me i madh ose i barabarte se njeqind.'); end; End.
  34. 34. Program shembull4; Var i : Integer; Begin Randomize; i := random(100); if i < 50 then WriteLn ( i, ' eshte me i vogel se 50.') else if i < 73 then WriteLn ( i, ' eshte me i madh ose i barabarte se 50, dhe me i vogel se 73.') else WriteLn ( i, ' eshte me i madh se 73.') End.
  35. 35. Shembull per te perdorur instruksionin case …. of Program shembull5; Var mosha : Integer; Begin Write(‘Shkruani moshen tuaj : '); Readln(mosha); case mosha of 18 : WriteLn(‘Ju jeni adolishent !'); 0..17 : WriteLn(‘Ju jeni nje femije qe levizni bashke me prindin...') 60..99 : WriteLn(‘Ju jeni nje prag pesionisti ose pesioniste ?!!!') else WriteLn(‘ju keni tjeter moshe...'); end ; End.
  36. 36. Shembull per te perdorur instruksionin For ….. Downto …. Dhe repeat…….until Program shembull8; Uses crt; Var i : Integer; Begin For i := 100 downto 0 do begin WriteLn ('Vlera e i : ', i ); end; End. Program shembull7; Var i : Integer; Begin Repeat Inc(i); Writeln (‘perserit ', i, ' here.'); until i > 20 ; End.
  37. 37. Program Exemple9b; Uses Crt; Procedure Maths (Param : Real); Begin WriteLn('Procédure de calcul. Veuillez patienter.'); Param := Sin(Sqrt(Param + 10)); WriteLn(Param); End; Var Nombre : Real; BEGIN ClrScr; Write('Entrez un nombre :'); ReadLn(Nombre); Maths(Nombre); ReadLn; END.
  38. 38. Program shembull9; Uses Crt; Procedure madhesia(var emri: String); Begin Write(‘vendosni emrin tuaj : '); ReadLn(emri); End; Procedure vendosni(Info : String); Begin WriteLn(‘emri juaj eshte : ', Info); End; Var varg: String; BEGIN ClrScr; madhesia(varg) ; vendosni(varg) ; Readln; END.
  39. 39. Program shembull10; Uses Crt; Function fuqia(i, j : Integer) : Integer; Var Rez, a : Integer ; Begin Rez := 1; for a := 1 to j do Rez:= Rez* i; fuqia := Rez; End; Var Rezultat, x, n : Integer; BEGIN Write(‘vendosni nje numer: '); ReadLn(x); Write(‘vendosni nje eksponent : '); ReadLn(n); Rezultat := fuqia(x,n); WriteLn(Rezultat); ReadLn; END. Shembull per ndertimin e nje funksioni
  40. 40. Shembull per te perdorur instruksionin sound per efekte zanore Program shembull12; Uses Crt; Var i, f : Integer; BEGIN for i := 1 to 20 do begin for f := 500 to 1000 do Sound(f); Delay(10); end; Nosound; END.
  41. 41. Shembull per perdorimin e variablit string dhe byte Program shembull24; Type varg = String[20]; Var emer : varg; mosha : Byte; BEGIN Write(‘shkruani emrin tuaj : '); ReadLn(emer); Write(‘vendosni moshen tuaj : '); ReadLn(mosha); WriteLn(‘Emri juaj eshte: ',emer,' dhe mosha juaj eshte : ',mosha); readln; END.
  42. 42. Program shembull14; Var emer : String; BEGIN emer:= ‘magdalena'; emer[2] := 'Z'; emer[0] := Chr(4); WriteLn(emer); emer[0] := Chr(28); Write(emer,'-tirana'); Readln; END. Program Exemple18; Uses Dos; Var Version : Word ; BEGIN Version := DosVersion; WriteLn('MS-DOS version : ',Lo(Version),'.',Hi(Version)); END.
  43. 43. Program shtyp; Var i, x : Integer; Begin x := 0 ; Repeat Inc(i); Break; x := 50; until i > 10; WriteLn(i); WriteLn(x); End. Program test_continue; Var i : Integer Begin i := 0; while i < 13 do begin Inc(i); if i < 10 then Continue; WriteLn('i = ',i); end; End.
  44. 44. Program Exemple19; Uses Dos; Var i : Integer; BEGIN for i := 1 to EnvCount do WriteLn(EnvStr(i)); END
  45. 45. Shembull per te lexuar hapesiren e lire te harddiskut ne bajt Progaram disk; Uses Dos; Var L : LongInt; Begin L := diskfree(3); Writeln(‘hapesira e lire ne harddisk C: ‘,L,’Bajt’); Readln; End.
  46. 46. Program funksioni; Uses crt; Var x,y : real; Begin Clrscr; Write(‘vlera e ndryshores x=‘); Readln(x); If x<9 then y:=sqr(x) Else If x=9 then y:=2*x Else y:=x-3; Writeln(‘rezultati y=‘,y:0:2); Readln; End.
  47. 47. program dallor; uses crt; var a,b,c,x1,x2,d,x : real; begin writeln('Jepni vleren e a,b,c te trinomit, a!=0'); readln(a,b,c); d := b*b-4*a*c; if d = 0 then begin x := -b/(2*a);
  48. 48. writeln('ekuacioni ka dy rrenje te bara. x1=x2=', x:4:2); end else if d > 0 then begin x1 := (-b+sqrt(d))/(2*a); x2 := (-b-sqrt(d))/(2*a); writeln ('ekuacioni ka dy rrenje te ndryshme', 'x1=', x1:0:2, 'x2=', x2:0:2); end else writeln('ekuacioni nuk ka rrenje reale'); readln; end.
  49. 49. Program for; Uses crt; Var x,y :char; Begin Clrscr; Randomize; For x:=‘Z’ downto ‘A’ do Begin For y:=‘A’ to x do begin Textcolor(1+randomize(15)); Write(y); Delay(250); End; Writeln; End; Readln; End.
  50. 50. Program çift_ose_tek; Uses crt; Var n : integer; tek : boolean; Begin Clrscr; Write(‘Vendosni nje numer te plote n=‘); Readln(n); Tek := odd(n); If tek then Writeln(‘Numri’,n,’ eshte tek’); Writeln(‘Numri’,n,’ eshte çift’); Readln; End.
  51. 51. Program faktorial; Uses crt; Var n,i : integer; F : real; Begin Clrscr; Write(‘Vlera e n eshte n=‘); Readln(n); F :=1; i:=1; While i<=n do Begin F := F*i; i := i*1; End; Writeln(‘Faktoriali i ‘,n,’! = ‘,F:0:2); Readln; End.
  52. 52. Program shuma_çift; Uses crt; Const n = 14; s : longint = 0; i : integer = 0; Begin Clrscr; Repeat S :=s+i; i :=i+2; Until i>n; writeln(‘Shuma e numrave çift eshte s=‘,s); Readln; End.
  53. 53. Program pjestuesi; Uses crt; Const v =‘______________________________________’; Var i,k : integer; Begin Clrscr; Write(‘pjestuesi: ‘); Readln(k); Writeln(v); Writeln(‘ i i div ‘,k,’ i mod ‘,k); Writeln(v); For i :=1 to 10 do Writeln(i:2,(i div k):8,(i mod k):10); Write(v); Readln; End.
  54. 54. Program perserit; Uses crt; Var p : char; Begin Clrscr; Repeat Writeln(^G); {Krijon hapesire nga rreshti dhe vendos nje shenje} Writw(‘A te perseritet ekzekutimi (P/J)?’); Readln(p); Until upcase(p) = ‘J’; End.
  55. 55. program ushtrim7; uses crt; var i : integer; begin clrscr; i :=0; while i <18 do begin inc (i); if i <10 then continue; writeln('i = ', i); end; readln; end.
  56. 56. Perdorimi I tabelave Program a; Const m = 8; x : Array[1..m] of Integer = (5,-7,8,4,-2,9,3,-1); Var i,s : Integer; Begin For i:=1 To m Do Begin If x[i] < 0 Then Continue; WriteLn(' x[',i,']= ',x[i]); s:=s+x[i]; End; WriteLn('Shuma s=',s); ReadLn; End.
  57. 57. Program dritare; Perdorimi instruksionit Uses Crt; Window dhe textcolor Var c : Byte; Begin Randomize; c:=Random(5); TextBackground(c); ClrScr; Window(5,4,40,20); TextBackground(c+1); TextColor(c+2); ClrScr; WriteLn('Teksti brenda dritares'); WriteLn('Me Enter - dritarja fshihet'); ReadLn; TextBackground(c+3); ClrScr; ReadLn; End.
  58. 58. Program koordinata; Perdorimi i instruksionit Uses Crt; GoTo dhe instruksionit Var i : Integer; cLreoL Begin; ClrScr; For i:=1 To 5 Do WriteLn(i:3,' Koha eshte e bukur'); GoToXY(10,3); TextBackground(2); ClrEol; ReadLn; End.
  59. 59. Program e_enjte; Program per Uses Crt; Perdorimin e instruksionit Var i: Byte; DeLLine dhe Delay Begin ClrScr; For i:=1 To 20 Do WriteLn('Rreshti i ',i:2); WriteLn('Me Enter - vazhdon ekzekutimi'); ReadLn; GoToXY(1,1); For i:=1 To 15 Do Begin DelLine; Delay (1000); End; ReadLn; End.
  60. 60. Program Dita; Const Pi=3.1415926; a='Rrezja e rrethit: '; b='Siperfaqja s='; c='Perimetri p='; Var r,s,p: Real; Begin Write(a); ReadLn(r); p:=2*Pi*r; s:=Pi*Sqr(r); WriteLn(b,s:7:3); WriteLn(c,p:7:3); ReadLn; End. Perdorimi i constantes dhe formatimit te perfundimit
  61. 61. Program Dita; Uses Crt; Const k = 'A'; Var i,n : Char; Begin ClrScr; Randomize; Write(‘Vendosni nje shkronje: '); ReadLn(n); For i:=k To n Do Begin TextColor(1+Random(15)); Write(i,' '); End; ReadLn; End. Perdorimi i textcolor dhe randomize randomize=> i zgjedhur rastesishte
  62. 62. Gjetja e elementeve negative te nje bashkesie Program tabela; Uses Crt; Const m = 5; A : Array[1..m] Of Integer = (3,-2,7,-4,5); Var i,n : Integer; Begin ClrScr; n:=0; For i:=1 To m Do If A[i]<0 Then n:=n+1; WriteLn('Anetare negativ n=',n); ReadLn; End.
  63. 63. Gjetja e elementeve pozitive dhe negative te nje bashkesie Program tabela; Uses Crt; Const m = 5; A : Array[1..m] Of Integer = (2,-3,-7,4,1); Var i,p,n : Integer; Begin ClrScr; p:=0; n:=0; For i:=1 To m Do If A[i]<0 Then n:=n+1 Else p:=p+1; WriteLn(‘Numra pozitiv p=',p); WriteLn(‘Numra negativ n=',n); ReadLn; End.
  64. 64. Gjetja e vleres maximale per variablin e tipit integer dhe longinteger Program Dita; Var a : Integer; b : LongInt; Begin a:=MaxInt; WriteLn('Vlera e konstantes MaxInt ......: ',a); b:=MaxLongInt; WriteLn('Vlera e konstantes MaxLongInt ..: ',b); ReadLn; End.
  65. 65. Menyre tjeter per gjetjen e sip. dhe perimetrit te rrethit Program 3; Const Pi=3.1415926; a='Rrezja e rrethit: '; b='Sip‰rfaqja s='; c='Perimetri p='; Var r,s,p: Real; Begin Write(a); ReadLn(r); p:=2*Pi*r; s:=Pi*Sqr(r); WriteLn(b,s:7:3); WriteLn(c,p:7:3); ReadLn; End.
  66. 66. Program per te treguar oren e kompjuterit Keypressed=>shtyp nje tast Program GetTime; per te ndaluar Uses Dos,Crt; Var Ora,Min,Sek,Sek_100 : Word; Begin ClrScr; TextColor(11); GoToXY(7,8);WriteLn('KOHA E KOMPJUTERIT'); Repeat GetTime(Ora,Min,Sek,Sek_100); TextColor(11); GoToXY(10,10);WriteLn('Ora : ',Ora:2); TextColor(11); GoToXY(10,12);WriteLn('Minuta : ',Min:2); TextColor(11); GoToXY(10,14);WriteLn('Sekonda : ',Sek:2); TextColor(11); GoToXY(10,16);WriteLn('Sek/100 : ',Sek_100:2); Until KeyPressed; End.

×