SlideShare une entreprise Scribd logo
1  sur  7
Pointers in C
By: Prof. Ganesh Ingle
Course Main Topic/Chapters
Introduction
Declaration of pointers & pointer to pointer
Concept of Pointer & Pointer to Pointer
Introduction
1. A pointer is a variable whose value is the
address of another variable, i.e., direct address
of the memory location. Like any variable or
constant, you must declare a pointer before
using it to store any variable address.
2. The actual data type of the value of all pointers,
whether integer, float, character, or otherwise,
is the same, a long hexadecimal number that
represents a memory address. The only
difference between pointers of different data
types is the data type of the variable or
constant that the pointer points to.
Declaration of a pointer
Concept of Pointer & Pointer to Pointer
1. If user want to store address of “a” which is of integer datatype to the pointer
variable then the pointer should be of same data type, i.e. integer.
2. Pointer variable stores address of another variable of similar data type
3. Pointer to pointer variable stores address of another pointer of similar data type
Concept of Pointer & Pointer to Pointer
1. // C program to demonstrate pointer and pointer to pointer
2. #include <stdio.h>
3. #include <conio.h>
4. #include <math.h>
5. #include <string.h>
6. void main()
7. {
8.
9. int a = 145;
10.
11. // pointer for a
12. int *ptr2;
13.
14. // double pointer for ptr2
15. int **ptr1;
16.
17. // storing address of a in ptr2
18. ptr2 = &a;
19.
20. // Storing address of ptr2 in ptr1
21. ptr1 = &ptr2;
22.
23. // Displaying value of a using
24. // both single and double pointers
25. printf("Value of a = %dn", a );
26. printf("Value of a using single pointer = %dn", *ptr2 );
27. printf("Value of a using double pointer = %dn", **ptr1);
28.
29. printf("Address of a = %un", &a );
30. printf("Address of a using single pointer = %un", ptr2 );
31. printf("Address of a using single pointer = %un", *ptr1);
32.
33. printf("Address of ptr2 using ptr2 = %un", &ptr2 );
34. printf("Address of ptr2 using ptr1 pointer to pointer = %un", ptr1 );
35.
36. }
THANK YOU
Image Source
searchenterpriseai.techtarget.com
wikipedia

Contenu connexe

Tendances

Tendances (19)

Main topic 3 problem solving and office automation
Main topic 3 problem solving and office automationMain topic 3 problem solving and office automation
Main topic 3 problem solving and office automation
 
C function
C functionC function
C function
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
Lecture 14 - Scope Rules
Lecture 14 - Scope RulesLecture 14 - Scope Rules
Lecture 14 - Scope Rules
 
Function in c
Function in cFunction in c
Function in c
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
Functions in C
Functions in CFunctions in C
Functions in C
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
 
Pointers lesson 5 (double pointer, call by value, call_by_reference)
Pointers lesson 5 (double pointer, call by value, call_by_reference)Pointers lesson 5 (double pointer, call by value, call_by_reference)
Pointers lesson 5 (double pointer, call by value, call_by_reference)
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Pointer to function 1
Pointer to function 1Pointer to function 1
Pointer to function 1
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 

Similaire à Pointers in C language

Similaire à Pointers in C language (20)

POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
 
Pointer introduction day1
Pointer introduction day1Pointer introduction day1
Pointer introduction day1
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
 
VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
 
Pointers
PointersPointers
Pointers
 
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
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
SPC Unit 3
SPC Unit 3SPC Unit 3
SPC Unit 3
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
4 Pointers.pptx
4 Pointers.pptx4 Pointers.pptx
4 Pointers.pptx
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Pointer in c
Pointer in c Pointer in c
Pointer in c
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 

Plus de Infinity Tech Solutions

Plus de Infinity Tech Solutions (20)

Database management system session 6
Database management system session 6Database management system session 6
Database management system session 6
 
Database management system session 5
Database management system session 5Database management system session 5
Database management system session 5
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Database Management System-session1-2
Database Management System-session1-2Database Management System-session1-2
Database Management System-session1-2
 
E commerce
E commerce E commerce
E commerce
 
E commerce
E commerceE commerce
E commerce
 
Bds session 13 14
Bds session 13 14Bds session 13 14
Bds session 13 14
 
Computer memory, Types of programming languages
Computer memory, Types of programming languagesComputer memory, Types of programming languages
Computer memory, Types of programming languages
 
Basic hardware familiarization
Basic hardware familiarizationBasic hardware familiarization
Basic hardware familiarization
 
User defined functions in matlab
User defined functions in  matlabUser defined functions in  matlab
User defined functions in matlab
 
Programming with matlab session 6
Programming with matlab session 6Programming with matlab session 6
Programming with matlab session 6
 
Programming with matlab session 3 notes
Programming with matlab session 3 notesProgramming with matlab session 3 notes
Programming with matlab session 3 notes
 
AI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime SectorAI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime Sector
 
Programming with matlab session 5 looping
Programming with matlab session 5 loopingProgramming with matlab session 5 looping
Programming with matlab session 5 looping
 
BIG DATA Session 7 8
BIG DATA Session 7 8BIG DATA Session 7 8
BIG DATA Session 7 8
 
BIG DATA Session 6
BIG DATA Session 6BIG DATA Session 6
BIG DATA Session 6
 
MS word
MS word MS word
MS word
 
DBMS CS 4-5
DBMS CS 4-5DBMS CS 4-5
DBMS CS 4-5
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
DBMS CS2
DBMS CS2DBMS CS2
DBMS CS2
 

Dernier

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 

Dernier (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 

Pointers in C language

  • 1. Pointers in C By: Prof. Ganesh Ingle
  • 2. Course Main Topic/Chapters Introduction Declaration of pointers & pointer to pointer Concept of Pointer & Pointer to Pointer
  • 3. Introduction 1. A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. 2. The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address. The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to.
  • 5. Concept of Pointer & Pointer to Pointer 1. If user want to store address of “a” which is of integer datatype to the pointer variable then the pointer should be of same data type, i.e. integer. 2. Pointer variable stores address of another variable of similar data type 3. Pointer to pointer variable stores address of another pointer of similar data type
  • 6. Concept of Pointer & Pointer to Pointer 1. // C program to demonstrate pointer and pointer to pointer 2. #include <stdio.h> 3. #include <conio.h> 4. #include <math.h> 5. #include <string.h> 6. void main() 7. { 8. 9. int a = 145; 10. 11. // pointer for a 12. int *ptr2; 13. 14. // double pointer for ptr2 15. int **ptr1; 16. 17. // storing address of a in ptr2 18. ptr2 = &a; 19. 20. // Storing address of ptr2 in ptr1 21. ptr1 = &ptr2; 22. 23. // Displaying value of a using 24. // both single and double pointers 25. printf("Value of a = %dn", a ); 26. printf("Value of a using single pointer = %dn", *ptr2 ); 27. printf("Value of a using double pointer = %dn", **ptr1); 28. 29. printf("Address of a = %un", &a ); 30. printf("Address of a using single pointer = %un", ptr2 ); 31. printf("Address of a using single pointer = %un", *ptr1); 32. 33. printf("Address of ptr2 using ptr2 = %un", &ptr2 ); 34. printf("Address of ptr2 using ptr1 pointer to pointer = %un", ptr1 ); 35. 36. }