SlideShare una empresa de Scribd logo
1 de 26
Chapter-7 Pointers
Pointers ,[object Object],[object Object],[object Object],[object Object],[object Object]
Pointers Variable in memory 1000 1001 1002 1003 1004 1005 1006 103 Memory address
The ‘&’ and ‘*’ ,[object Object],[object Object],[object Object],[object Object],[object Object]
The ‘&’ and ‘*’ 3 ab 1000 Location name Value at Location Address
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The ‘&’ and ‘*’ ,[object Object],[object Object],[object Object],[object Object]
An Example:Pointers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Output: Address of j = 1000 Value of j = 5 Value of j = 5
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A program that prints out pointers and the values they point to:
Write a program that computes the area and perimeter of a rectangle: #include <stdio.h> void rectangle(int a, int b, int  * area, int  * perim); int main() { int x, y; int area, perim; printf(&quot;Enter two values separated by space: &quot; ); scanf(&quot;%d %d&quot;, &x, &y); rectangle(x, y, &area, &perim); printf(&quot;Area is %d Perimeter is %d&quot;, area, perim); return 0; } void rectangle(int a,int b,int  * area,int  * perim) { *area = a * b; *perim = 2 * (a + b); }
Pointer Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Pointer Assignments ,[object Object],Here i’s value is 5 and j’s value is i’s address. i 5 1000 1000 2000 j
Pointer Assignments ,[object Object],[object Object]
An Example:Pointer Assignments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Output: Address of j = 1000 Address of j = 1000 Address of k = 2000 Value of k = 1000 Value of j = 3 Value of j = 3 Value of j = error
Pointer Conversions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pointers v/s Arrays ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Output: Embedded Embedded
Pointers v/s Arrays ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis: Pointers v/s Arrays ,[object Object],[object Object]
Arrays of Pointers ,[object Object],[object Object]
An Example: Arrays of Pointers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arrays of Pointers 1000 2500 2000 1500 i 5 10 j 20 15 l k 2500 2000 1500 1000 arr[0] arr[3] arr[2] arr[1] 1200 2700 2200 1700
Pointers To Pointers ,[object Object],[object Object]
Double Pointers 3 i 1000 1000 2000 j 2000 3000 k
Double Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Double Pointer OUTPUT: Address of i is 1000 1000 1000 Address of j is 2000 2000 Address of k is 3000  Value of i is 3 3 3 3 Value of j is 1000 Value of k is 2000
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

C programming pointer
C  programming pointerC  programming pointer
C programming pointerargusacademy
 
9. pointer, pointer & function
9. pointer, pointer & function9. pointer, pointer & function
9. pointer, pointer & function웅식 전
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Languagemadan reddy
 
CSE240 Macros and Preprocessing
CSE240 Macros and PreprocessingCSE240 Macros and Preprocessing
CSE240 Macros and PreprocessingGarrett Gutierrez
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c languagegourav kottawar
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer웅식 전
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3karmuhtam
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
C Pointers
C PointersC Pointers
C Pointersomukhtar
 
Module 02 Pointers in C
Module 02 Pointers in CModule 02 Pointers in C
Module 02 Pointers in CTushar B Kute
 

La actualidad más candente (20)

C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 
SPC Unit 3
SPC Unit 3SPC Unit 3
SPC Unit 3
 
9. pointer, pointer & function
9. pointer, pointer & function9. pointer, pointer & function
9. pointer, pointer & function
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Ponters
PontersPonters
Ponters
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
CSE240 Macros and Preprocessing
CSE240 Macros and PreprocessingCSE240 Macros and Preprocessing
CSE240 Macros and Preprocessing
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
 
C pointer basics
C pointer basicsC pointer basics
C pointer basics
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer
 
pointers
pointerspointers
pointers
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
C Pointers
C PointersC Pointers
C Pointers
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Module 02 Pointers in C
Module 02 Pointers in CModule 02 Pointers in C
Module 02 Pointers in C
 

Destacado

Social Networking in the Business World: A Strategic Approach
Social Networking in the Business World: A Strategic ApproachSocial Networking in the Business World: A Strategic Approach
Social Networking in the Business World: A Strategic Approachlinkedinlion11
 
Medical Terminology
Medical TerminologyMedical Terminology
Medical Terminologygnaz786
 
Marketing
MarketingMarketing
Marketingtlopezv
 
Donald Clark Citizens And Netizens Weapons Of Mass Collaboration
Donald Clark   Citizens And Netizens Weapons Of Mass CollaborationDonald Clark   Citizens And Netizens Weapons Of Mass Collaboration
Donald Clark Citizens And Netizens Weapons Of Mass CollaborationJMHarkin
 

Destacado (8)

Projectrapport
ProjectrapportProjectrapport
Projectrapport
 
Lan texto
Lan textoLan texto
Lan texto
 
Social Networking in the Business World: A Strategic Approach
Social Networking in the Business World: A Strategic ApproachSocial Networking in the Business World: A Strategic Approach
Social Networking in the Business World: A Strategic Approach
 
Blog profissional
Blog profissionalBlog profissional
Blog profissional
 
Medical Terminology
Medical TerminologyMedical Terminology
Medical Terminology
 
Tesj008
Tesj008Tesj008
Tesj008
 
Marketing
MarketingMarketing
Marketing
 
Donald Clark Citizens And Netizens Weapons Of Mass Collaboration
Donald Clark   Citizens And Netizens Weapons Of Mass CollaborationDonald Clark   Citizens And Netizens Weapons Of Mass Collaboration
Donald Clark Citizens And Netizens Weapons Of Mass Collaboration
 

Similar a Ch 7-pointers

Similar a Ch 7-pointers (20)

C pointers and references
C pointers and referencesC pointers and references
C pointers and references
 
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdfEASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
iit c prog.ppt
iit c prog.pptiit c prog.ppt
iit c prog.ppt
 
Chapter5.pptx
Chapter5.pptxChapter5.pptx
Chapter5.pptx
 
VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3
 
Chapter 13.1.8
Chapter 13.1.8Chapter 13.1.8
Chapter 13.1.8
 
Ponters
PontersPonters
Ponters
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Lk module5 pointers
Lk module5 pointersLk module5 pointers
Lk module5 pointers
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
 
Pointers.pptx
Pointers.pptxPointers.pptx
Pointers.pptx
 
Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
 
4 Pointers.pptx
4 Pointers.pptx4 Pointers.pptx
4 Pointers.pptx
 
Engineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptxEngineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptx
 
Pointers.pdf
Pointers.pdfPointers.pdf
Pointers.pdf
 

Último

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Último (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Ch 7-pointers

  • 2.
  • 3. Pointers Variable in memory 1000 1001 1002 1003 1004 1005 1006 103 Memory address
  • 4.
  • 5. The ‘&’ and ‘*’ 3 ab 1000 Location name Value at Location Address
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Write a program that computes the area and perimeter of a rectangle: #include <stdio.h> void rectangle(int a, int b, int * area, int * perim); int main() { int x, y; int area, perim; printf(&quot;Enter two values separated by space: &quot; ); scanf(&quot;%d %d&quot;, &x, &y); rectangle(x, y, &area, &perim); printf(&quot;Area is %d Perimeter is %d&quot;, area, perim); return 0; } void rectangle(int a,int b,int * area,int * perim) { *area = a * b; *perim = 2 * (a + b); }
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Arrays of Pointers 1000 2500 2000 1500 i 5 10 j 20 15 l k 2500 2000 1500 1000 arr[0] arr[3] arr[2] arr[1] 1200 2700 2200 1700
  • 22.
  • 23. Double Pointers 3 i 1000 1000 2000 j 2000 3000 k
  • 24.
  • 25. Double Pointer OUTPUT: Address of i is 1000 1000 1000 Address of j is 2000 2000 Address of k is 3000 Value of i is 3 3 3 3 Value of j is 1000 Value of k is 2000
  • 26.