SlideShare a Scribd company logo
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
POINTERS
Static Variables && Dynamic Variables 
Static Variables : 
var x:integer; 
The memory for this variables x still until program End , and doesn’t free even we don’t use it 
Ex: 
X 
Memory 
We determine their places at memory first of all 
value
Dynamic Variables : 
Memory 
The Heap 
X 
var x: ^integer; 
Ex: 
the address 
the address 
value 
The memory for this variables x in the Heap, we can take it or dispose it, so it can be free!! 
We determine their places at memory during the program
Why Dynamic?? 
1) better usage to memory 
2) to create advance data structure like trees , lists….atc
What is the pointer? 
The Definition 
The pointer is an address to a memory place 
Var ptr: ^Type; 
Lets Have an explication!! but…..
P1 
X 
Value.. 
P1^ 
P1 
Var p1,p2: ^Type; x :Type; 
P1^ 
P1 
P1^ 
X:=value 
P2 
xx 
P1^ 
P2 
New(p1); 
P1^:=x 
Value.. 
P2:=P1 
Value.. 
P1:=nil; 
Value.. 
+1
xx 
P1^ 
P2 
Dispose(p2); 
Value.. 
xx 
P1^ 
xx 
P2:=nil; 
Value.. 
+1
Program pointer on Soso; 
There is wrong ! 
Type 
pEmp=^Emp; 
Emp=Record 
eno:integer; ename:string[20]; 
esal:real; 
end; 
Var 
E:Emp; E1:pEmp; 
n,m,y:^integer; 
EXAMPLE:
Begin i:=5; new(y); y^:=50; write(y); write(^y); write(y^); y:=i y^:=i ; y^:=20; i:=y^; y:=0; dispose(y); y:=nil; new(m); new(y); m^:=30; y^:=80; n:=y; write(y^); write(n^); E1:=nil; new(E1); E1^:=E ; Read(E1^.Eno); Dispose(E1); End. 
false 
false 
TRUE 
NOTE: Without “ New(n)” !! 
80 80 
false 
TRUE
STACK {FILO} 
First In Last Out 
pringles
The Data 
next 
Nil 
TOP 
Stack=Record 
the Data: Type; 
next: Pstack; 
end; 
The Definition 
Pstack=^stack; 
Var 
Top: Pstack; 
D:Type; 
……….
Stack procedures : 
Push(s,ch) 
Pop(s,ch) 
S_Top(s,ch) 
Is_Empty(s) 
3) 
2) 
1) 
4)
EX: You have a string “KiKi” How to put/take it in /from the STACK ?! 
i 
next 
TOP 
K 
i 
K 
Nil
Stack=Record ch: char; next: Pstack; end; 
Type Pstack=^stack; 
Var Top: Pstack; st: string[4]; i:integer; x:char; 
BEGIN 
Readln(st); top:=nil; 
For i:=1 to (length(st) ) do 
push( top, st[i] ) ; 
While(top<>Nil) do 
begin 
Pop( top, x) ; write(x,’ ’); 
end; 
END. 
Program fifi;
PUSH 
Procedure push (var Top:Pstack; c:char); Var temp:Pstack; Begin end; 
new(temp); 
temp^.ch:=c; 
temp^.next:=top; 
top:=temp; 
i 
next 
TOP 
K 
i 
K 
Nil 
temp 
K 
TOP 
i 
TOP 
K 
TOP 
i
Stack=Record 
ch: char; 
next: Pstack; 
end; 
Type Pstack=^stack; 
Var Top: Pstack; st: string[4]; i:integer; x:char; 
BEGIN 
Readln(st); top:=nil; 
For i:=1 to (length(st) ) 
push( top, st[i] ) ; 
While(top<>Nil) do 
begin 
Pop( top, x) ; write(x,’ ’); 
end; 
END. 
Program fifi;
POP 
Procedure pop (var Top:Pstack; var c:char); 
Var temp:Pstack; 
Begin 
end; 
Dispose(temp); 
Temp:=Top; 
Top:=Top^.next ; 
C:=top^.ch; 
i 
next 
TOP 
K 
i 
K 
Nil 
The output: 
C 
i 
temp 
K 
TOP 
temp 
TOP 
i 
temp 
TOP 
K 
temp 
i 
K 
i 
K
Stack=Record ch: char; next: Pstack; end; 
Type Pstack=^stack; 
Var Top: Pstack; st: string[4]; i:integer; x:char; 
BEGIN 
Readln(st); top:=nil; 
For i:=1 to (length(st)-1) 
push( top, st[i] ) ; 
begin 
Pop( top, x) ; write(x,’ ’); 
end; 
END. 
Program fifi; 
While(top<>Nil) do
Is_Empty 
Function Is_Empty (top:Pstack):boolean begin if top =Nil then Is_Empty:=True; else Is_Empty:=false; end;
S_Top 
Function s_Top (top:Pstack): integer/…Type begin if not is_Empty(top) then s_Top :=top^.key; end; 
NOTE: Don’t write then : top:=top^.next 
Cause that function just return the element without change in stack!!
NOTE: 
You can reach to the data , at a determinate place by pointers without do pop() cause with pop() you cant restoring your ‘poped’ data .. You do: S:=top; {bring the third element 64} i:=s^.next^.next^.key; OR: S:=top; {bring the 11 element} For i:=1 to 10 do s:=s^.next; i:=s^.key 
52 
next 
TOP 
35 
64 
76 
Nil 
S 
+1
Homework: 
لديك تعبير حسابي مثلا : 
(( (1 * (3+2)) * 1) +3 ) 
المطلىب : 
حساب قيمة التعبير الحسابي وطباعتها على 
الشاشة باستخدام المكدس pop/push 
ملاحظة :مكدس واحد فقط ! 
+20 points
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot

Introduction To Stack
Introduction To StackIntroduction To Stack
Introduction To Stack
Education Front
 
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
Bhavesh Sanghvi
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
chetan handa
 
skip list
skip listskip list
skip list
iammutex
 
Stack
StackStack
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
Ashis Kumar Chanda
 
A1 11 functions
A1 11 functionsA1 11 functions
A1 11 functionsvhiggins1
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
Sayantan Sur
 
Stack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxStack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptx
sandeep54552
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
EktaVaswani2
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
Geunhyung Kim
 
Stack
StackStack
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup GroupJava 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Henri Tremblay
 
Stack_Data_Structure.pptx
Stack_Data_Structure.pptxStack_Data_Structure.pptx
Stack_Data_Structure.pptx
sandeep54552
 
Push down automata
Push down automataPush down automata
Push down automata
Ratnakar Mikkili
 

What's hot (20)

Introduction To Stack
Introduction To StackIntroduction To Stack
Introduction To Stack
 
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
skip list
skip listskip list
skip list
 
Stack
StackStack
Stack
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
 
A1 11 functions
A1 11 functionsA1 11 functions
A1 11 functions
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Stack
StackStack
Stack
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
 
Stack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxStack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptx
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
 
Stack
StackStack
Stack
 
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup GroupJava 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
 
Stack_Data_Structure.pptx
Stack_Data_Structure.pptxStack_Data_Structure.pptx
Stack_Data_Structure.pptx
 
Push down automata
Push down automataPush down automata
Push down automata
 
Stack queue
Stack queueStack queue
Stack queue
 

Similar to 2Bytesprog2 course_2014_c5_pointers

stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
CrazyKiller4
 
C++ Program It is only 1 rotation. Up-rotation of a stack. Write a.pdf
C++ Program It is only 1 rotation. Up-rotation of a stack.  Write a.pdfC++ Program It is only 1 rotation. Up-rotation of a stack.  Write a.pdf
C++ Program It is only 1 rotation. Up-rotation of a stack. Write a.pdf
pallavi953613
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdf
Asrinath1
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
Stack
StackStack
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
Stack data structure
Stack data structureStack data structure
Stack data structure
rogineojerio020496
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
vsssuresh
 
data structure
data structuredata structure
data structure
Arvind Kumar
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
Divya Kumari
 
iPython
iPythoniPython
iPython
Aman Lalpuria
 
ds-10.pdf
ds-10.pdfds-10.pdf
ds-10.pdf
VanshGarg64
 
Stacks
StacksStacks
Stacks
Sadaf Ismail
 
04 stacks
04 stacks04 stacks
04 stacks
Rajan Gautam
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 

Similar to 2Bytesprog2 course_2014_c5_pointers (20)

stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
 
C++ Program It is only 1 rotation. Up-rotation of a stack. Write a.pdf
C++ Program It is only 1 rotation. Up-rotation of a stack.  Write a.pdfC++ Program It is only 1 rotation. Up-rotation of a stack.  Write a.pdf
C++ Program It is only 1 rotation. Up-rotation of a stack. Write a.pdf
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdf
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
Stack
StackStack
Stack
 
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
 
Ch8a
Ch8aCh8a
Ch8a
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
data structure
data structuredata structure
data structure
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
 
iPython
iPythoniPython
iPython
 
ds-10.pdf
ds-10.pdfds-10.pdf
ds-10.pdf
 
Stacks
StacksStacks
Stacks
 
04 stacks
04 stacks04 stacks
04 stacks
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 

More from kinan keshkeh

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

More from kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
 

Recently uploaded

Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 

Recently uploaded (20)

Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 

2Bytesprog2 course_2014_c5_pointers

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 3. Static Variables && Dynamic Variables Static Variables : var x:integer; The memory for this variables x still until program End , and doesn’t free even we don’t use it Ex: X Memory We determine their places at memory first of all value
  • 4. Dynamic Variables : Memory The Heap X var x: ^integer; Ex: the address the address value The memory for this variables x in the Heap, we can take it or dispose it, so it can be free!! We determine their places at memory during the program
  • 5. Why Dynamic?? 1) better usage to memory 2) to create advance data structure like trees , lists….atc
  • 6. What is the pointer? The Definition The pointer is an address to a memory place Var ptr: ^Type; Lets Have an explication!! but…..
  • 7. P1 X Value.. P1^ P1 Var p1,p2: ^Type; x :Type; P1^ P1 P1^ X:=value P2 xx P1^ P2 New(p1); P1^:=x Value.. P2:=P1 Value.. P1:=nil; Value.. +1
  • 8. xx P1^ P2 Dispose(p2); Value.. xx P1^ xx P2:=nil; Value.. +1
  • 9. Program pointer on Soso; There is wrong ! Type pEmp=^Emp; Emp=Record eno:integer; ename:string[20]; esal:real; end; Var E:Emp; E1:pEmp; n,m,y:^integer; EXAMPLE:
  • 10. Begin i:=5; new(y); y^:=50; write(y); write(^y); write(y^); y:=i y^:=i ; y^:=20; i:=y^; y:=0; dispose(y); y:=nil; new(m); new(y); m^:=30; y^:=80; n:=y; write(y^); write(n^); E1:=nil; new(E1); E1^:=E ; Read(E1^.Eno); Dispose(E1); End. false false TRUE NOTE: Without “ New(n)” !! 80 80 false TRUE
  • 11. STACK {FILO} First In Last Out pringles
  • 12. The Data next Nil TOP Stack=Record the Data: Type; next: Pstack; end; The Definition Pstack=^stack; Var Top: Pstack; D:Type; ……….
  • 13. Stack procedures : Push(s,ch) Pop(s,ch) S_Top(s,ch) Is_Empty(s) 3) 2) 1) 4)
  • 14. EX: You have a string “KiKi” How to put/take it in /from the STACK ?! i next TOP K i K Nil
  • 15. Stack=Record ch: char; next: Pstack; end; Type Pstack=^stack; Var Top: Pstack; st: string[4]; i:integer; x:char; BEGIN Readln(st); top:=nil; For i:=1 to (length(st) ) do push( top, st[i] ) ; While(top<>Nil) do begin Pop( top, x) ; write(x,’ ’); end; END. Program fifi;
  • 16. PUSH Procedure push (var Top:Pstack; c:char); Var temp:Pstack; Begin end; new(temp); temp^.ch:=c; temp^.next:=top; top:=temp; i next TOP K i K Nil temp K TOP i TOP K TOP i
  • 17. Stack=Record ch: char; next: Pstack; end; Type Pstack=^stack; Var Top: Pstack; st: string[4]; i:integer; x:char; BEGIN Readln(st); top:=nil; For i:=1 to (length(st) ) push( top, st[i] ) ; While(top<>Nil) do begin Pop( top, x) ; write(x,’ ’); end; END. Program fifi;
  • 18. POP Procedure pop (var Top:Pstack; var c:char); Var temp:Pstack; Begin end; Dispose(temp); Temp:=Top; Top:=Top^.next ; C:=top^.ch; i next TOP K i K Nil The output: C i temp K TOP temp TOP i temp TOP K temp i K i K
  • 19. Stack=Record ch: char; next: Pstack; end; Type Pstack=^stack; Var Top: Pstack; st: string[4]; i:integer; x:char; BEGIN Readln(st); top:=nil; For i:=1 to (length(st)-1) push( top, st[i] ) ; begin Pop( top, x) ; write(x,’ ’); end; END. Program fifi; While(top<>Nil) do
  • 20. Is_Empty Function Is_Empty (top:Pstack):boolean begin if top =Nil then Is_Empty:=True; else Is_Empty:=false; end;
  • 21. S_Top Function s_Top (top:Pstack): integer/…Type begin if not is_Empty(top) then s_Top :=top^.key; end; NOTE: Don’t write then : top:=top^.next Cause that function just return the element without change in stack!!
  • 22. NOTE: You can reach to the data , at a determinate place by pointers without do pop() cause with pop() you cant restoring your ‘poped’ data .. You do: S:=top; {bring the third element 64} i:=s^.next^.next^.key; OR: S:=top; {bring the 11 element} For i:=1 to 10 do s:=s^.next; i:=s^.key 52 next TOP 35 64 76 Nil S +1
  • 23. Homework: لديك تعبير حسابي مثلا : (( (1 * (3+2)) * 1) +3 ) المطلىب : حساب قيمة التعبير الحسابي وطباعتها على الشاشة باستخدام المكدس pop/push ملاحظة :مكدس واحد فقط ! +20 points
  • 24. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team