SlideShare a Scribd company logo
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
Let’s Remember!! SomeOf Prog_1 :D
Program 2Bytes_pro; 
Uses wincrt; 
Var k,x,y,z :integer; 
Procedure proc1(a:integer; var b:integer ;) 
var i,x: integer; 
Begin 
i:=10; x:=7; y:=12; a:=2; b:=4; 
end; 
Begin 
x:=3; y:=5; proc1(k,z); 
Writeln(„z=„,z); 
Writeln(„k=„,k); 
Writeln(„x=„,x); 
Writeln(„y=„,y); 
Writeln(„i=„,i); 
End. 
+1 
+1 
+1 
+1 
+1 
{ z=4 } 
{Random value often be zero} 
{ x=3 } 
{ y=12 } 
{ error }
In procedures and functions There are four types of variables : 
1.General Variables : are variables that are written at the top of the program befor all procedures and functions and we can see it and deal with it by all procedures and functions in the main program (like : k , x , y , z) . 
2.Local Variables : are variables that are declared in the statements part within procedure or function and we can‟t see it and deal with it outside that procedures (like : i , x ) . 
3.Formality Variables : are variables that appear in the header of procedure or function and it is formality and is not reserved place for it in memory (like a , b ) 
 we have two types of formality variables 
1) input variables : Keeps the value entered by after the completion of the procedural ( like : a) 
2)output variables : Keeps the value obtained by the procedure. And we writes before it the reserved word (var) (like : b ) 
4.Actual Variables : are variables that main program pass it to procedure or function during a summons and it agree formality variables in number and type (like : k , z)
Notes : 
Local variables have priority from general variables in the same Field of vision ( ايؤرنا لاجي ) ( like : x) 
 Execution always start form (begin) by the main program 
 in string : 
var : name , lname : string ; 
begin writeln(„enter the name and lname „); 
readln(name , lname); 
writeln(name); 
writeln(lname); 
End. 
Ahmed 
Ali 
Inputs : 
Ahmed Ali 
X nothing 
outputs 
name); 
readln(lname); 
+1
SETS 
A П B 
A 
B
What is a DiscreteType?? 
Discrete Data Type: 
Integer 
boolean 
char 
Enumerated 
Day=(sat,sun,mon,tu,wed,th,fri) 
Like..
Definition 
The SET is a Data Structure which contain discrete type elements .. 
Doesn‟t have index.!! 
<Nameof varible > :Set of < discrete type > 
We can‟t define the set as this form : 
S : Set of Integer; 
Because set can have 256 components at most and all its component values should be in rang 0 .. 255 .
Ex: 
•S1 : Set of 1..100; 
•S2 : Set of „a‟..‟z‟; 
•S : Set of Days; 
•S : Set of 66..256; 
•S: set of char ; 
{True} 
{True} 
{True} 
{False} 
+1 
{True}
Set Handling 
Var: 
s1:set of 0..255; 
S2,s3:set of 40..100; 
S4:set of „a‟..‟z‟;
S1 := [ 55, 80, 99, 80, 600, 41, 44..55]; 
Isn‟t added 
S1: 
41 44..55 80 99
S1 : 
S1 := [];
S2 := [200,20]; 
S2: 
40..100 
“NO Change”
S4 := [‘B’,’A’,’c’,’a’]; 
S4: 
„a‟ „c‟
S4 := [I,k]; 
Var I,k:integer; 
i:=1; k:=k+1; 
+1 
S4: 
Compile Error !!
S1 := [I,j]; 
Var I,j:integer; 
i:=1; j:=i*9; 
+1 
S1: 
1,9
i, j : integer; i := 1; j := i-1; S1 := [i, j]; S1 := S1 + [i*2]; 
S1: 
0,1,2 
+1
S1:=S4; 
+1 
Error 
Ya fahmaneen !! :D
Operation 
•To put a value in it , we use [value] . 
•The operations on Sets : 
⋂ ⇔ * 
⋃ ⇔ + 
/ ⇔ - 
⊆ ⇔ <= 
⊇ ⇔ >= 
∈ ⇔ in
Program SetsOperator; Var A0 : set of 1..15; A1 : set of 1..10; A2 : set of 5..15; i : integer; Begin A1 := [1..10]; A2 := [5..15]; A0 := A1*A2; {A0=[5..10]} A0 := A1+A2; {A0=[1..15]} A0 := A1-A2; {A0=[1..4]} A0 := A0-[1]; {A0=[2..4]}
A1 := [2,3]; 
A2 := [1,2,3,4,5]; 
if (A1 <= A2) then {or (A2 >= A1)} 
writeln ('A1 is a subset of A2'); 
readln (i); 
if (i in A1) then 
writeln (i,' is in A1') 
else 
writeln (i,' is not in A1'); 
End;
True statement 
A0, A1 : Set of 1..15; A : boolean; A0 := [1, 2]; A1 := [2, 4]; A0 := A0 – [77]; A := A1 >= A0; A := 1 in A0;
Const Sets 
Type 
Digits = set of 0..9; 
Const 
HexD : set of '0'..'z‘ = 
['0'..'9', 'A'..'F', 'a'..'f']; 
ED : Digits = [0, 2, 4, 6, 8]; 
Var 
d : Digits; 
Begin 
d := [8]; 
d := ED; {d=[0,2,4,6,8]} 
ED:=ED+[9]; 
ED:=d; 
End. 
+1 
Error .. Fateh 3eoonk !!
Enum Set 
Type 
Day = (sun,mon,….,sat); 
Name=(koko,soso,fofo,fifi); 
Var 
days: Set of Day; 
N:set of Name 
Begin 
Days:=[sun..sat]; 
N:=[KOKO,SOSO]; 
End.
Read & Print Sets :
Program Test(); Type SInt = Set of 1..150 ; SCh = Set of ‘0’..’z’; Var S1 : SInt; S2 : SCh; Slen : Integer; Begin Readln(Slen); ReadsetI(S1 , Slen); ReadsetC(S2 , Slen); PrintsetI(S1 , Slen); PrintsetC(S2 , Slen); Readln; End.
Read Integer Sets 
Procedure ReadsetI (var S:SInt; L:integer) ; 
var 
i, x : integer; 
Begin 
s:=[]; 
For i:=1 to L do 
begin 
Read(x); 
S := S + [x]; 
end; 
End;
Read Char Sets 
Procedure ReadsetC (var S:SCh; L:integer) ; var i, x : Char; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
Print Integer Sets Using While Loop: 
Procedure PrintsetI (S : SInt) ; 
var 
I : Integer; 
Begin 
I := 0; 
While ( S <> []) do 
If (I in S) then 
begin 
Writeln(I); 
S := S – [I]; 
end; 
I := I + 1; 
End;
Print Integer Sets Using For Loop 
Procedure PrintsetI (S : SI) ; var I : Integer; Begin For I:=1 to 32700 do Begin If (I in S) then Begin Writeln(I); S := S – [I]; End; If (S = []) then I := 32700; End; End;
Exercise : 
يرى في يؼهذ يا إػطاء دوراخ في يادذي انرياضياخ وانهغح الإ كَهيسيح 
يؼطى كم طانة ػ ذُ ذسجيهه في ان ؼًهذ رقى فريذ يحصىر تي 1..100 فإرا ػه دً أ ػذد انطلاب في كم يادج لا يرجاوز 50 طانة 
ان طًهىب كراتح تر اَيج ػاو تاسرخذاو الاجرائياخ وان جً ىًػاخ ورنك 
نهقياو تان هًاو انرانيح : 
. 
1 ذشكيم يج ىًػح نطلاب انرياضياخ ويج ىًػح نطلاب انهغح 
الإ كَهيسيح )إدخال ػ اُصر ان جً ىًػح ( 
. 
2 إجراء نطثاػح ػ اُصر ان جً ىًػح 
. 
3 إجراء لإػطاء يج ىًػح تأرقاو انطلاب ان سًجهي تان اًدذي . 
4 قررخ إدارج ان ؼًهذ ذخفيض ػذد انطلاب ورنك تالاسرغ اُء ػ ػذد 
يحذد ي هُى يذخم ي نىحح ان فًاذيح ػهى أ يرى اخريار أرقاو 
انطلاب ان فًصىني تشكم ػشىائي وان طًهىب كراتح إجراء ن قُم 
أرقاو انطلاب ان فًصىني إنى يج ىًػح جذيذج 
. 
5 وضغ أرقاو انطلاب ان فًصىني ض شؼاع
Program prog2byte_team; 
Uses wincrt; 
Type students=set of 1..100; 
numbers=array[1..50] of 1..100; 
Var seng,smath : students; 
Procedure inputset(var s : students; m:integer); 
Var i,x: integer; 
Begin 
s:=[ ]; 
i:=0; 
While (i<m) do 
begin 
writeln(„input students number „); 
readln(x); 
if (x in s) then 
writeln(„ you input this number befor please enter 
another number „) 
else 
begin 
i:=i+1; 
s:=s+[x]; 
end; 
end; 
End; 
numbers of students
Procedure printset(s :students); 
Var i:integer; 
Begin 
i:=1; 
While (s<>[ ]) do 
begin 
if (i in s) then 
begin 
write(i:5); 
s:=s-[ i ]; 
end; 
i:=i+1; 
end; 
writeln; 
End;
Procedure bothsub(s1,s2 : students; var s3: students); 
Begin 
s3:=s1*s2; 
End;
Procedure deletestd(var s,n : students); 
Var k,i,x ; integer; 
Begin 
n:= [ ]; 
Randomize; 
i:=0; 
Writeln(„enter the number you want to go throw out „); 
Readln(x); 
While (i<x) do 
begin 
k:= random(100) + 1; 
if ( k in s ) then 
begin 
s:=s – [ k ]; 
seng:= seng – [ k ]; 
smath:=smath – [ k ]; 
i:=i+1; 
n:=n + [ k ]; 
end; 
end; 
End; 
بلاطنا حػىًجي 
ان فًصىني يج ىًػح 
انرقاطغ 
:Randomize يقىو ترىنيذ 
أرقاو ػشىائيح أػر اًدا ػهى 
ساػح ان ظُاو 
:Random(100)=0..99; 
Random(100)+1=1..100
Procedure setinArray(s: students; var a: numbers ; var k: integer); 
Var i : integer; 
Begin 
K:=0; 
For i:=1 to 100 do 
If (i in s) then 
begin 
k:=k+1; 
a[k]:=i; 
end; 
End; 
ي أجم اسرذػاء 
انشؼاع في انثر اَيج 
انرئيسي
Var nmath,neng,k,i :integer; 
Aunaccepted : numbers; 
Sunaccepted,sboth : students; 
Begin 
Writeln(„enter the number of math students „); 
Readln(nmath); 
Inputset(smath,nmath); 
Writeln(„enter the number of English students „); 
Readln(neng); 
Inputset(seng,neng); 
Bothsub(smath , seng , sboth); 
Printset(sboth); 
Deletestd(sboth,Sunaccepted); 
Printset(Sunaccepted); 
setinArray(Sunaccepted,Aunaccepted,k); 
For i:=1 to k do 
Writeln(Aunaccepted[i]:5); 
Readln; 
End.
Homework: 
Creat and read two arrays of student numbers, student numbers in Prog and in English. 
-We want to know the students numbers at the two subjects..?! 
-what are the student numbers at the Prog and Not at English ?? 
+10 point
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team
Revision Practise
Ques: 
write a programme DO: 
1-Read An Array 2-Print An Array//Proce 
3-function to find the min elem in the array 
4-Procedure to find the Sum array(of the tow arrays). 
5- Multi array 
Write the Main Program..
Programme P-Matrix; 
Const nMax=20; mMax=20; 
Type Matrix=array[1..nmax,1..mmax] of real; 
Var A,B,Add,mult :Matrix; 
n1,n2 :1..nmax; 
m1,m2 :1..mmax; 
min: integer;
Procedure ReadMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); 
Var i,j:integer; 
begin 
writeln(„enter the first Dimention of matrix< ‟ ,nmax); 
Readln(n); 
writeln(„enter the second Dimention of matrix< ‟ ,mmax); 
Readln(m); 
for i:=1 to n do 
begin 
for j:=1 to m do read(A[I,j]); {hint} 
readln; {hint} 
end; 
end;
Procedure WriteMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); 
Var i,j:integer; 
begin 
for i:=1 to n do 
begin 
for j:=1 to m do write(A[i,j],‟ ‟); 
writeln; 
end; 
end;
Function MinOfMatrix(n:1..nmax,m:1..mmax;A:matrix):real 
Var i,j:integer; min:real; 
begin 
min:=A[1,1]; 
For i:=1 to n do 
for j:=1 to m do 
if (A[i,j]<min) then 
min:=A[i,j]; 
MinOfMatrix:=min; 
end;
Procedure Add_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); 
Var i,j:integer; 
begin 
if(n1<>n2)or(m1<>m2) then 
writeln(„the addition is impossible‟); 
else 
begin 
n3:=n1; m3:=m1; 
for i:=1 to n3 do 
for j:=1 to m3 do 
C[i.j]:=A[i,j]+B[i,j]; 
end; 
end;
Procedure Mult_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); 
Var i,j,k:integer; 
begin 
if(n1<>m2) then 
writeln(„the multi is impossible‟); 
else 
begin 
n3:=n2; m3:=m1; { A(m1,n1)*B(m2,n2)=C(m3,n3)} 
for i:=1 to n3 do 
for j:=1 to m3 do 
begin 
C[i,j]=0; 
for k:=1 to m2 
C[i.j]:= C[i.j] +A[i,k]*B[k,j]; 
end; 
end; 
end;
Begin 
ReadMat(n1,m1,A); WriteMat(n1,m1,A); 
ReadMat(n2,m2,B); WriteMat(n2,m2,B); 
writeln(„the minimum of the first Mat = ‟); 
min:=MinOfMatrix(n1,m1,A); writeln(min); 
Add_Tow_Matrix(n1.m1,n2,m2,A,B,n3,m3,Add); 
WriteMat(n3,m3,Add); 
Mult_Tow_Matrix(n1,n2,m1,m2,A,B, n3,m3,mult); 
WriteMat(n3,m3,mult); 
End;
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot (20)

PDF
Scope Graphs: A fresh look at name binding in programming languages
Eelco Visser
 
PDF
c-programming-using-pointers
Sushil Mishra
 
PDF
C programs
Vikram Nandini
 
DOC
Ada file
Kumar Gaurav
 
PDF
Lec23-CS110 Computational Engineering
Sri Harsha Pamu
 
PDF
Crafting Custom Interfaces with Sub::Exporter
Ricardo Signes
 
PDF
The Death of Final Tagless
John De Goes
 
PDF
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
PDF
M|18 User Defined Functions
MariaDB plc
 
PDF
C program
Komal Singh
 
PDF
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
PDF
Functional Stream Processing with Scalaz-Stream
Adil Akhter
 
KEY
Scalaz
mpilquist
 
PDF
Side by Side - Scala and Java Adaptations of Martin Fowler’s Javascript Refac...
Philip Schwarz
 
PDF
FS2 for Fun and Profit
Adil Akhter
 
PDF
java sockets
Enam Ahmed Shahaz
 
PDF
BCSL 058 solved assignment
Indira Gnadhi National Open University (IGNOU)
 
PPTX
Templates in C++
Tech_MX
 
DOCX
Data Structure Project File
Deyvessh kumar
 
Scope Graphs: A fresh look at name binding in programming languages
Eelco Visser
 
c-programming-using-pointers
Sushil Mishra
 
C programs
Vikram Nandini
 
Ada file
Kumar Gaurav
 
Lec23-CS110 Computational Engineering
Sri Harsha Pamu
 
Crafting Custom Interfaces with Sub::Exporter
Ricardo Signes
 
The Death of Final Tagless
John De Goes
 
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
M|18 User Defined Functions
MariaDB plc
 
C program
Komal Singh
 
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Functional Stream Processing with Scalaz-Stream
Adil Akhter
 
Scalaz
mpilquist
 
Side by Side - Scala and Java Adaptations of Martin Fowler’s Javascript Refac...
Philip Schwarz
 
FS2 for Fun and Profit
Adil Akhter
 
java sockets
Enam Ahmed Shahaz
 
Templates in C++
Tech_MX
 
Data Structure Project File
Deyvessh kumar
 

Similar to 2Bytesprog2 course_2014_c1_sets (20)

PDF
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PPTX
Csci101 lect03 algorithms_i
Elsayed Hemayed
 
PDF
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
PDF
Plc (1)
James Croft
 
PPTX
Problem Solving PPT Slides Grade 10- 11students
chamm5
 
DOCX
UNIT-1.docx Design and Analysis of Algorithm
swethajosephsastry
 
PPT
Cs341
Serghei Urban
 
PDF
Sets c1
Omar Al-Sabek
 
PPTX
Data structure using c module 1
smruti sarangi
 
PPSX
Problem solving and design
Renée Howard-Johnson
 
PPTX
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
PDF
Arrays c4 c5
Omar Al-Sabek
 
PDF
Abap basics 01
yours4ever002
 
PDF
intro arr-search.pdfintro arr-search.pdf
timoemin50
 
PPTX
Unit 1 Introduction Part 3.pptx
NishaRohit6
 
PDF
Design and Analysis Algorithms.pdf
HarshNagda5
 
PDF
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
 
PPTX
Design and Analysis of Algorithms.pptx
DeepikaV81
 
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
Csci101 lect03 algorithms_i
Elsayed Hemayed
 
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
Plc (1)
James Croft
 
Problem Solving PPT Slides Grade 10- 11students
chamm5
 
UNIT-1.docx Design and Analysis of Algorithm
swethajosephsastry
 
Sets c1
Omar Al-Sabek
 
Data structure using c module 1
smruti sarangi
 
Problem solving and design
Renée Howard-Johnson
 
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
Arrays c4 c5
Omar Al-Sabek
 
Abap basics 01
yours4ever002
 
intro arr-search.pdfintro arr-search.pdf
timoemin50
 
Unit 1 Introduction Part 3.pptx
NishaRohit6
 
Design and Analysis Algorithms.pdf
HarshNagda5
 
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
 
Design and Analysis of Algorithms.pptx
DeepikaV81
 
Ad

More from kinan keshkeh (20)

PDF
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
PDF
Simpson and lagranje dalambair math methods
kinan keshkeh
 
PDF
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
PDF
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
PDF
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
PDF
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c9_graph
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c8_ strings
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c4_ arrays
kinan keshkeh
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
Simpson and lagranje dalambair math methods
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
kinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
kinan keshkeh
 
2 BytesC++ course_2014_c8_ strings
kinan keshkeh
 
2 BytesC++ course_2014_c4_ arrays
kinan keshkeh
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 

2Bytesprog2 course_2014_c1_sets

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 3. Program 2Bytes_pro; Uses wincrt; Var k,x,y,z :integer; Procedure proc1(a:integer; var b:integer ;) var i,x: integer; Begin i:=10; x:=7; y:=12; a:=2; b:=4; end; Begin x:=3; y:=5; proc1(k,z); Writeln(„z=„,z); Writeln(„k=„,k); Writeln(„x=„,x); Writeln(„y=„,y); Writeln(„i=„,i); End. +1 +1 +1 +1 +1 { z=4 } {Random value often be zero} { x=3 } { y=12 } { error }
  • 4. In procedures and functions There are four types of variables : 1.General Variables : are variables that are written at the top of the program befor all procedures and functions and we can see it and deal with it by all procedures and functions in the main program (like : k , x , y , z) . 2.Local Variables : are variables that are declared in the statements part within procedure or function and we can‟t see it and deal with it outside that procedures (like : i , x ) . 3.Formality Variables : are variables that appear in the header of procedure or function and it is formality and is not reserved place for it in memory (like a , b )  we have two types of formality variables 1) input variables : Keeps the value entered by after the completion of the procedural ( like : a) 2)output variables : Keeps the value obtained by the procedure. And we writes before it the reserved word (var) (like : b ) 4.Actual Variables : are variables that main program pass it to procedure or function during a summons and it agree formality variables in number and type (like : k , z)
  • 5. Notes : Local variables have priority from general variables in the same Field of vision ( ايؤرنا لاجي ) ( like : x)  Execution always start form (begin) by the main program  in string : var : name , lname : string ; begin writeln(„enter the name and lname „); readln(name , lname); writeln(name); writeln(lname); End. Ahmed Ali Inputs : Ahmed Ali X nothing outputs name); readln(lname); +1
  • 6. SETS A П B A B
  • 7. What is a DiscreteType?? Discrete Data Type: Integer boolean char Enumerated Day=(sat,sun,mon,tu,wed,th,fri) Like..
  • 8. Definition The SET is a Data Structure which contain discrete type elements .. Doesn‟t have index.!! <Nameof varible > :Set of < discrete type > We can‟t define the set as this form : S : Set of Integer; Because set can have 256 components at most and all its component values should be in rang 0 .. 255 .
  • 9. Ex: •S1 : Set of 1..100; •S2 : Set of „a‟..‟z‟; •S : Set of Days; •S : Set of 66..256; •S: set of char ; {True} {True} {True} {False} +1 {True}
  • 10. Set Handling Var: s1:set of 0..255; S2,s3:set of 40..100; S4:set of „a‟..‟z‟;
  • 11. S1 := [ 55, 80, 99, 80, 600, 41, 44..55]; Isn‟t added S1: 41 44..55 80 99
  • 12. S1 : S1 := [];
  • 13. S2 := [200,20]; S2: 40..100 “NO Change”
  • 15. S4 := [I,k]; Var I,k:integer; i:=1; k:=k+1; +1 S4: Compile Error !!
  • 16. S1 := [I,j]; Var I,j:integer; i:=1; j:=i*9; +1 S1: 1,9
  • 17. i, j : integer; i := 1; j := i-1; S1 := [i, j]; S1 := S1 + [i*2]; S1: 0,1,2 +1
  • 18. S1:=S4; +1 Error Ya fahmaneen !! :D
  • 19. Operation •To put a value in it , we use [value] . •The operations on Sets : ⋂ ⇔ * ⋃ ⇔ + / ⇔ - ⊆ ⇔ <= ⊇ ⇔ >= ∈ ⇔ in
  • 20. Program SetsOperator; Var A0 : set of 1..15; A1 : set of 1..10; A2 : set of 5..15; i : integer; Begin A1 := [1..10]; A2 := [5..15]; A0 := A1*A2; {A0=[5..10]} A0 := A1+A2; {A0=[1..15]} A0 := A1-A2; {A0=[1..4]} A0 := A0-[1]; {A0=[2..4]}
  • 21. A1 := [2,3]; A2 := [1,2,3,4,5]; if (A1 <= A2) then {or (A2 >= A1)} writeln ('A1 is a subset of A2'); readln (i); if (i in A1) then writeln (i,' is in A1') else writeln (i,' is not in A1'); End;
  • 22. True statement A0, A1 : Set of 1..15; A : boolean; A0 := [1, 2]; A1 := [2, 4]; A0 := A0 – [77]; A := A1 >= A0; A := 1 in A0;
  • 23. Const Sets Type Digits = set of 0..9; Const HexD : set of '0'..'z‘ = ['0'..'9', 'A'..'F', 'a'..'f']; ED : Digits = [0, 2, 4, 6, 8]; Var d : Digits; Begin d := [8]; d := ED; {d=[0,2,4,6,8]} ED:=ED+[9]; ED:=d; End. +1 Error .. Fateh 3eoonk !!
  • 24. Enum Set Type Day = (sun,mon,….,sat); Name=(koko,soso,fofo,fifi); Var days: Set of Day; N:set of Name Begin Days:=[sun..sat]; N:=[KOKO,SOSO]; End.
  • 25. Read & Print Sets :
  • 26. Program Test(); Type SInt = Set of 1..150 ; SCh = Set of ‘0’..’z’; Var S1 : SInt; S2 : SCh; Slen : Integer; Begin Readln(Slen); ReadsetI(S1 , Slen); ReadsetC(S2 , Slen); PrintsetI(S1 , Slen); PrintsetC(S2 , Slen); Readln; End.
  • 27. Read Integer Sets Procedure ReadsetI (var S:SInt; L:integer) ; var i, x : integer; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
  • 28. Read Char Sets Procedure ReadsetC (var S:SCh; L:integer) ; var i, x : Char; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
  • 29. Print Integer Sets Using While Loop: Procedure PrintsetI (S : SInt) ; var I : Integer; Begin I := 0; While ( S <> []) do If (I in S) then begin Writeln(I); S := S – [I]; end; I := I + 1; End;
  • 30. Print Integer Sets Using For Loop Procedure PrintsetI (S : SI) ; var I : Integer; Begin For I:=1 to 32700 do Begin If (I in S) then Begin Writeln(I); S := S – [I]; End; If (S = []) then I := 32700; End; End;
  • 31. Exercise : يرى في يؼهذ يا إػطاء دوراخ في يادذي انرياضياخ وانهغح الإ كَهيسيح يؼطى كم طانة ػ ذُ ذسجيهه في ان ؼًهذ رقى فريذ يحصىر تي 1..100 فإرا ػه دً أ ػذد انطلاب في كم يادج لا يرجاوز 50 طانة ان طًهىب كراتح تر اَيج ػاو تاسرخذاو الاجرائياخ وان جً ىًػاخ ورنك نهقياو تان هًاو انرانيح : . 1 ذشكيم يج ىًػح نطلاب انرياضياخ ويج ىًػح نطلاب انهغح الإ كَهيسيح )إدخال ػ اُصر ان جً ىًػح ( . 2 إجراء نطثاػح ػ اُصر ان جً ىًػح . 3 إجراء لإػطاء يج ىًػح تأرقاو انطلاب ان سًجهي تان اًدذي . 4 قررخ إدارج ان ؼًهذ ذخفيض ػذد انطلاب ورنك تالاسرغ اُء ػ ػذد يحذد ي هُى يذخم ي نىحح ان فًاذيح ػهى أ يرى اخريار أرقاو انطلاب ان فًصىني تشكم ػشىائي وان طًهىب كراتح إجراء ن قُم أرقاو انطلاب ان فًصىني إنى يج ىًػح جذيذج . 5 وضغ أرقاو انطلاب ان فًصىني ض شؼاع
  • 32. Program prog2byte_team; Uses wincrt; Type students=set of 1..100; numbers=array[1..50] of 1..100; Var seng,smath : students; Procedure inputset(var s : students; m:integer); Var i,x: integer; Begin s:=[ ]; i:=0; While (i<m) do begin writeln(„input students number „); readln(x); if (x in s) then writeln(„ you input this number befor please enter another number „) else begin i:=i+1; s:=s+[x]; end; end; End; numbers of students
  • 33. Procedure printset(s :students); Var i:integer; Begin i:=1; While (s<>[ ]) do begin if (i in s) then begin write(i:5); s:=s-[ i ]; end; i:=i+1; end; writeln; End;
  • 34. Procedure bothsub(s1,s2 : students; var s3: students); Begin s3:=s1*s2; End;
  • 35. Procedure deletestd(var s,n : students); Var k,i,x ; integer; Begin n:= [ ]; Randomize; i:=0; Writeln(„enter the number you want to go throw out „); Readln(x); While (i<x) do begin k:= random(100) + 1; if ( k in s ) then begin s:=s – [ k ]; seng:= seng – [ k ]; smath:=smath – [ k ]; i:=i+1; n:=n + [ k ]; end; end; End; بلاطنا حػىًجي ان فًصىني يج ىًػح انرقاطغ :Randomize يقىو ترىنيذ أرقاو ػشىائيح أػر اًدا ػهى ساػح ان ظُاو :Random(100)=0..99; Random(100)+1=1..100
  • 36. Procedure setinArray(s: students; var a: numbers ; var k: integer); Var i : integer; Begin K:=0; For i:=1 to 100 do If (i in s) then begin k:=k+1; a[k]:=i; end; End; ي أجم اسرذػاء انشؼاع في انثر اَيج انرئيسي
  • 37. Var nmath,neng,k,i :integer; Aunaccepted : numbers; Sunaccepted,sboth : students; Begin Writeln(„enter the number of math students „); Readln(nmath); Inputset(smath,nmath); Writeln(„enter the number of English students „); Readln(neng); Inputset(seng,neng); Bothsub(smath , seng , sboth); Printset(sboth); Deletestd(sboth,Sunaccepted); Printset(Sunaccepted); setinArray(Sunaccepted,Aunaccepted,k); For i:=1 to k do Writeln(Aunaccepted[i]:5); Readln; End.
  • 38. Homework: Creat and read two arrays of student numbers, student numbers in Prog and in English. -We want to know the students numbers at the two subjects..?! -what are the student numbers at the Prog and Not at English ?? +10 point
  • 39. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team
  • 41. Ques: write a programme DO: 1-Read An Array 2-Print An Array//Proce 3-function to find the min elem in the array 4-Procedure to find the Sum array(of the tow arrays). 5- Multi array Write the Main Program..
  • 42. Programme P-Matrix; Const nMax=20; mMax=20; Type Matrix=array[1..nmax,1..mmax] of real; Var A,B,Add,mult :Matrix; n1,n2 :1..nmax; m1,m2 :1..mmax; min: integer;
  • 43. Procedure ReadMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); Var i,j:integer; begin writeln(„enter the first Dimention of matrix< ‟ ,nmax); Readln(n); writeln(„enter the second Dimention of matrix< ‟ ,mmax); Readln(m); for i:=1 to n do begin for j:=1 to m do read(A[I,j]); {hint} readln; {hint} end; end;
  • 44. Procedure WriteMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); Var i,j:integer; begin for i:=1 to n do begin for j:=1 to m do write(A[i,j],‟ ‟); writeln; end; end;
  • 45. Function MinOfMatrix(n:1..nmax,m:1..mmax;A:matrix):real Var i,j:integer; min:real; begin min:=A[1,1]; For i:=1 to n do for j:=1 to m do if (A[i,j]<min) then min:=A[i,j]; MinOfMatrix:=min; end;
  • 46. Procedure Add_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); Var i,j:integer; begin if(n1<>n2)or(m1<>m2) then writeln(„the addition is impossible‟); else begin n3:=n1; m3:=m1; for i:=1 to n3 do for j:=1 to m3 do C[i.j]:=A[i,j]+B[i,j]; end; end;
  • 47. Procedure Mult_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); Var i,j,k:integer; begin if(n1<>m2) then writeln(„the multi is impossible‟); else begin n3:=n2; m3:=m1; { A(m1,n1)*B(m2,n2)=C(m3,n3)} for i:=1 to n3 do for j:=1 to m3 do begin C[i,j]=0; for k:=1 to m2 C[i.j]:= C[i.j] +A[i,k]*B[k,j]; end; end; end;
  • 48. Begin ReadMat(n1,m1,A); WriteMat(n1,m1,A); ReadMat(n2,m2,B); WriteMat(n2,m2,B); writeln(„the minimum of the first Mat = ‟); min:=MinOfMatrix(n1,m1,A); writeln(min); Add_Tow_Matrix(n1.m1,n2,m2,A,B,n3,m3,Add); WriteMat(n3,m3,Add); Mult_Tow_Matrix(n1,n2,m1,m2,A,B, n3,m3,mult); WriteMat(n3,m3,mult); End;
  • 49. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team