Pascal Programming Language
Omar ElSabek & Fayez Ghazzawi
IT Engineering
3th year – UNKNOWN Department
programming II
Welcome!
Hope you are doing fine!
Sets
 Record
Files (Text & Binary)
Pointers
 Linked Lists
 Unit
Course Index :
What Do we need !
• Let’s Begin learning the SETS
Sets
A set is a collection of elements of same type.
Pascal allows defining the set data type.
The elements in a set are called members. In Pascal, sets are
represented by enclosing the members within square brackets [ ]
The Proprieties
• items can not be repeated
• ordinal
• discrete
• finite (in Pascal the maximum size of set is
256 item)
1. We CAN’T repeat values in a single Set
2. We should define the Set as aType
3. In the arrays we can get the value of an element inside by
array[Num].
But here …….We just can’t 
4. The max number of elements in the Set is 255 element
5. All the elements inside have the sameType (integer ,char
,boolean ,enumerated)
Type
set-identifier = set of base type ;
Var
s1, s2, ... : set-identifier;
Type
Color = (red, blue, yellow, green, white);
Var
s1, s2 : Color ;
Type
Color = (red, blue, yellow, green, white);
Days = (Mon, tue, wed, thu, fri, sat, sun);
Letters = set of char;
Alphabets = set of 'A' .. 'Z';
Examples:
Re-initialization
initialization
S1 = set of integer;
S2 = Set of 1..300
S3 = Set of char;
Program Lesson1_Program1 (input,output);
Type
Days = (Sun, Mon,Tue,Wed,Thu, Fri, Sat);
Var
D : days
Begin
writeln (days(2)); { outputTue}
readln;
End.
Program Lesson1_Program1 (input,output);
Type
Days = (Sun, Mon,Tue,Wed,Thu, Fri, Sat);
Var
D : days
Begin
writeln (ord(Mon)); { output 1}
readln;
End.
CanWe Define a Set in “Var” ????
Var
S : set of 1..70 ;
Remembering
the ‘:’
17
S1 := [40, 55, 99, 40, 41, 44..55, 300];
40 41 55..99
Won’t add
S1
• The operations on Sets :
 ⋂ ⇔ *
 ⋃ ⇔ +
 / ⇔ -
 ⊆ ⇔ <=
 ⊇ ⇔ >=
 ∈ ⇔ in
19
20
Procedure ReadsetI (var S:SI; L:integer) ;
var
i, x : integer;
Begin
For i:=1 to L do
begin
Read(x);
S := S + [x];
end;
End;

EnumeratedType
Car= (kia,BMW,Toyota,ZTR,Mazda)
Sets c1

Sets c1