SlideShare une entreprise Scribd logo
1  sur  27
POINTERS IN C++
POINTERS  :  Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object]
POINTERS  :  Introduction ,[object Object],[object Object],[object Object]
Uses of Pointers ,[object Object],[object Object],[object Object],[object Object],[object Object]
DECLARATION AND INITIALIZATION OF POINTERS ,[object Object],[object Object],[object Object],[object Object],[object Object]
TYPES OF POINTERS ,[object Object],[object Object],[object Object],[object Object],Type of variable pointed to by ptr Reference operator Name of the pointer Type of variable pointed to by z Name of the pointer Reference operator
[object Object],[object Object],[object Object],[object Object],Currently p is not pointing to any variable 76.50 marks A variable of type float If following statement is added in the above program segment: p = & marks; The variable p will point to marks of the type float as shown below: 76.50 marks p A variable of type float Now pointer p is pointing to marks p
[object Object],[object Object],[object Object],[object Object],[object Object]
Null Pointer ,[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
THE ‘ADDRESS OF’ OPERATOR (&) ,[object Object],[object Object],[object Object],[object Object],[object Object],n 15 1000 1001 Address of x memory Two bytes required for storing one integer
VALUE AT OPERATOR ( * ) ,[object Object],[object Object],[object Object],[object Object],NOTE :  The operand of  &  operator is any variable but operand of  *  operator is  essentially a pointer variable.
MEMORY ALLOCATION ,[object Object],[object Object],STACK HEAP GLOBAL VAR . PROG. CODE Area used for function calls, addresses, arguments and local variables Area used for  dynamic allocation  of memory
Static And Dynamic Memory Allocation  ,[object Object],[object Object],[object Object]
Memory Management :  Operators  new  and  delete   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  new   Operator ,[object Object],[object Object],[object Object],[object Object],[object Object]
For example: ,[object Object],[object Object],[object Object],n Heap memory ptr Memory space for  5 int
Free Storage Pool ,[object Object]
The  delete   Operator ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],The  delete   Operator (Contd.)
[object Object],[object Object],Memory Leaks Reasons for Memory Leak ,[object Object],[object Object],[object Object]
Give the output of the following: Pointer  prg1.cpp #include <iostream.h> #include <conio.h> void  main() {  clrscr(); int * ptr; int i=25; ptr=&i; cout<<i<<‘’; cout<<&i<<‘’; cout<<ptr<<‘’; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
Give the output of the following: Pointer  prg2.cpp #include <iostream.h> #include <conio.h> void  main() {  clrscr(); char * cp; char ch=‘a’; cp=& ch; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
Give the output of the following: Pointer  prg3.cpp #include <iostream.h> #include <conio.h> void  main() {  clrscr(); char *p1,*p2,*p3; int x=5; int y=7; p1=&x; p2=&y; cout << “original values are : “;<<*p1<<*p2; p3=p1; p1=p2; p2=p3;  cout << “exchanged values are : “;<<*p1<<*p2; getch(); }
Arithmetic of Pointers ,[object Object],[object Object]
So, if we write: Assume following pointers: int *iptr;// //assume it points to location 1000 char *cptr; //assume it points to location 2000 float *fptr; //assume it points to location 3000 iptr++;  //iptr will be incremented by 2 cptr++;  //cptr will be incremented by 1 fptr++;  //fptr will be incremented by 4
n Heap memory iptr 1000 1002 int *iptr;// //assume it points to location 1000 n Heap memory iptr 1000 1002 iptr++;  //iptr will be incremented by 2

Contenu connexe

Tendances (20)

Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Friend function
Friend functionFriend function
Friend function
 
This pointer
This pointerThis pointer
This pointer
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
 
Function in C
Function in CFunction in C
Function in C
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)
 
C Pointers
C PointersC Pointers
C Pointers
 
String functions in C
String functions in CString functions in C
String functions in C
 
The Stack And Recursion
The Stack And RecursionThe Stack And Recursion
The Stack And Recursion
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
String functions and operations
String functions and operations String functions and operations
String functions and operations
 

En vedette

pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismrattaj
 
Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]Abdullah khawar
 
Operating Systems - Intro to C++
Operating Systems - Intro to C++Operating Systems - Intro to C++
Operating Systems - Intro to C++Emery Berger
 
Maharashtra hsc board previous year papers
Maharashtra hsc board  previous year papersMaharashtra hsc board  previous year papers
Maharashtra hsc board previous year papersHSC.co.in
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in CUri Dekel
 
intro to pointer C++
intro to  pointer C++intro to  pointer C++
intro to pointer C++Ahmed Farag
 
Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Ali Aminian
 
Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort AlgorithmTobias Straub
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topicSaddam Hussain
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...cprogrammings
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++Laxman Puri
 
Career Option after 10+2
Career Option after 10+2Career Option after 10+2
Career Option after 10+2vishalgarodia
 

En vedette (20)

C++ Pointers
C++ PointersC++ Pointers
C++ Pointers
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
 
Pointers
PointersPointers
Pointers
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
 
Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]
 
Operating Systems - Intro to C++
Operating Systems - Intro to C++Operating Systems - Intro to C++
Operating Systems - Intro to C++
 
Maharashtra hsc board previous year papers
Maharashtra hsc board  previous year papersMaharashtra hsc board  previous year papers
Maharashtra hsc board previous year papers
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
 
intro to pointer C++
intro to  pointer C++intro to  pointer C++
intro to pointer C++
 
Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2
 
Bubblesort Algorithm
Bubblesort AlgorithmBubblesort Algorithm
Bubblesort Algorithm
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Exception handling
Exception handlingException handling
Exception handling
 
Inheritance
InheritanceInheritance
Inheritance
 
Career Option after 10+2
Career Option after 10+2Career Option after 10+2
Career Option after 10+2
 

Similaire à Introduction to Pointers in C (20)

COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
Chapter16 pointer
Chapter16 pointerChapter16 pointer
Chapter16 pointer
 
Pointers
PointersPointers
Pointers
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Pointer
PointerPointer
Pointer
 
C pointer
C pointerC pointer
C pointer
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Advanced pointers
Advanced pointersAdvanced pointers
Advanced pointers
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
 
Lecture 18 - Pointers
Lecture 18 - PointersLecture 18 - Pointers
Lecture 18 - Pointers
 
358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3
 
4 Pointers.pptx
4 Pointers.pptx4 Pointers.pptx
4 Pointers.pptx
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
Advanced+pointers
Advanced+pointersAdvanced+pointers
Advanced+pointers
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
 
C Programming Unit-4
C Programming Unit-4C Programming Unit-4
C Programming Unit-4
 
Pointers
PointersPointers
Pointers
 

Plus de tech4us

Kmap Slideshare
Kmap SlideshareKmap Slideshare
Kmap Slidesharetech4us
 
Kmap Slideshare
Kmap SlideshareKmap Slideshare
Kmap Slidesharetech4us
 
Cruched Eau
Cruched EauCruched Eau
Cruched Eautech4us
 
Stacks & Queues
Stacks & QueuesStacks & Queues
Stacks & Queuestech4us
 
eBeam : Intractive Whiteboard System
eBeam : Intractive Whiteboard SystemeBeam : Intractive Whiteboard System
eBeam : Intractive Whiteboard Systemtech4us
 

Plus de tech4us (8)

Edge1
Edge1Edge1
Edge1
 
Kmap Slideshare
Kmap SlideshareKmap Slideshare
Kmap Slideshare
 
Kmap Slideshare
Kmap SlideshareKmap Slideshare
Kmap Slideshare
 
Cruched Eau
Cruched EauCruched Eau
Cruched Eau
 
Sql
SqlSql
Sql
 
Rdbms
RdbmsRdbms
Rdbms
 
Stacks & Queues
Stacks & QueuesStacks & Queues
Stacks & Queues
 
eBeam : Intractive Whiteboard System
eBeam : Intractive Whiteboard SystemeBeam : Intractive Whiteboard System
eBeam : Intractive Whiteboard System
 

Dernier

Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
Unlocking the Secrets of Affiliate Marketing.pdf
Unlocking the Secrets of Affiliate Marketing.pdfUnlocking the Secrets of Affiliate Marketing.pdf
Unlocking the Secrets of Affiliate Marketing.pdfOnline Income Engine
 
Understanding the Pakistan Budgeting Process: Basics and Key Insights
Understanding the Pakistan Budgeting Process: Basics and Key InsightsUnderstanding the Pakistan Budgeting Process: Basics and Key Insights
Understanding the Pakistan Budgeting Process: Basics and Key Insightsseri bangash
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Centuryrwgiffor
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Lviv Startup Club
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...lizamodels9
 
Best Basmati Rice Manufacturers in India
Best Basmati Rice Manufacturers in IndiaBest Basmati Rice Manufacturers in India
Best Basmati Rice Manufacturers in IndiaShree Krishna Exports
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetCreating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetDenis Gagné
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayNZSG
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Event mailer assignment progress report .pdf
Event mailer assignment progress report .pdfEvent mailer assignment progress report .pdf
Event mailer assignment progress report .pdftbatkhuu1
 

Dernier (20)

Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
Unlocking the Secrets of Affiliate Marketing.pdf
Unlocking the Secrets of Affiliate Marketing.pdfUnlocking the Secrets of Affiliate Marketing.pdf
Unlocking the Secrets of Affiliate Marketing.pdf
 
Understanding the Pakistan Budgeting Process: Basics and Key Insights
Understanding the Pakistan Budgeting Process: Basics and Key InsightsUnderstanding the Pakistan Budgeting Process: Basics and Key Insights
Understanding the Pakistan Budgeting Process: Basics and Key Insights
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...
Call Girls In Holiday Inn Express Gurugram➥99902@11544 ( Best price)100% Genu...
 
Best Basmati Rice Manufacturers in India
Best Basmati Rice Manufacturers in IndiaBest Basmati Rice Manufacturers in India
Best Basmati Rice Manufacturers in India
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature SetCreating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
Creating Low-Code Loan Applications using the Trisotech Mortgage Feature Set
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Event mailer assignment progress report .pdf
Event mailer assignment progress report .pdfEvent mailer assignment progress report .pdf
Event mailer assignment progress report .pdf
 

Introduction to Pointers in C

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. Give the output of the following: Pointer prg1.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); int * ptr; int i=25; ptr=&i; cout<<i<<‘’; cout<<&i<<‘’; cout<<ptr<<‘’; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
  • 23. Give the output of the following: Pointer prg2.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); char * cp; char ch=‘a’; cp=& ch; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
  • 24. Give the output of the following: Pointer prg3.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); char *p1,*p2,*p3; int x=5; int y=7; p1=&x; p2=&y; cout << “original values are : “;<<*p1<<*p2; p3=p1; p1=p2; p2=p3; cout << “exchanged values are : “;<<*p1<<*p2; getch(); }
  • 25.
  • 26. So, if we write: Assume following pointers: int *iptr;// //assume it points to location 1000 char *cptr; //assume it points to location 2000 float *fptr; //assume it points to location 3000 iptr++; //iptr will be incremented by 2 cptr++; //cptr will be incremented by 1 fptr++; //fptr will be incremented by 4
  • 27. n Heap memory iptr 1000 1002 int *iptr;// //assume it points to location 1000 n Heap memory iptr 1000 1002 iptr++; //iptr will be incremented by 2