SlideShare a Scribd company logo
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

More Related Content

PDF
User Defined Functions in C Language
PPTX
Function Pointer in C
PPTX
Function Pointer
PPT
Lecture 11 - Functions
PPTX
functions in C
PDF
C standard library functions
PDF
Introduction to c programming
DOCX
Maharishi University of Management (MSc Computer Science test questions)
User Defined Functions in C Language
Function Pointer in C
Function Pointer
Lecture 11 - Functions
functions in C
C standard library functions
Introduction to c programming
Maharishi University of Management (MSc Computer Science test questions)

What's hot (19)

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

Similar to Pointers in C language (20)

PDF
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
PPT
Pointer introduction day1
PDF
PSPC--UNIT-5.pdf
PPTX
Arrays to arrays and pointers with arrays.pptx
PDF
VIT351 Software Development VI Unit3
PDF
Pointers-Computer programming
PPTX
Unit-4-1.pptxjtjrjfjfjfjfjfjfjfjrjrjrjrjejejeje
PDF
Pointers
PDF
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
PPTX
Pointers in C
PPT
SPC Unit 3
PPT
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
PPTX
Pointer in C
PDF
Pointers in C
PPTX
4 Pointers.pptx
PPTX
Pointer in c
PPTX
Pointer in c
PPTX
Structured programming Unit-6-Strings-Unit-8-Pointer.pptx
PPTX
pointers.pptx
PPTX
pointers.pptx
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
Pointer introduction day1
PSPC--UNIT-5.pdf
Arrays to arrays and pointers with arrays.pptx
VIT351 Software Development VI Unit3
Pointers-Computer programming
Unit-4-1.pptxjtjrjfjfjfjfjfjfjfjrjrjrjrjejejeje
Pointers
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
Pointers in C
SPC Unit 3
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Pointer in C
Pointers in C
4 Pointers.pptx
Pointer in c
Pointer in c
Structured programming Unit-6-Strings-Unit-8-Pointer.pptx
pointers.pptx
pointers.pptx
Ad

More from Infinity Tech Solutions (20)

PDF
Database management system session 6
PDF
Database management system session 5
PDF
Database Management System-session 3-4-5
PDF
Database Management System-session1-2
PDF
PDF
Bds session 13 14
PDF
Computer memory, Types of programming languages
PDF
Basic hardware familiarization
PDF
User defined functions in matlab
PDF
Programming with matlab session 6
PDF
Programming with matlab session 3 notes
PPTX
AI/ML/DL/BCT A Revolution in Maritime Sector
PDF
Programming with matlab session 5 looping
PDF
BIG DATA Session 7 8
PDF
BIG DATA Session 6
PDF
Database management system session 6
Database management system session 5
Database Management System-session 3-4-5
Database Management System-session1-2
Bds session 13 14
Computer memory, Types of programming languages
Basic hardware familiarization
User defined functions in matlab
Programming with matlab session 6
Programming with matlab session 3 notes
AI/ML/DL/BCT A Revolution in Maritime Sector
Programming with matlab session 5 looping
BIG DATA Session 7 8
BIG DATA Session 6

Recently uploaded (20)

PPTX
Sustainable Sites - Green Building Construction
PDF
PPT on Performance Review to get promotions
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Well-logging-methods_new................
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
composite construction of structures.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Welding lecture in detail for understanding
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Sustainable Sites - Green Building Construction
PPT on Performance Review to get promotions
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
bas. eng. economics group 4 presentation 1.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Well-logging-methods_new................
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
CH1 Production IntroductoryConcepts.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
composite construction of structures.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Welding lecture in detail for understanding
OOP with Java - Java Introduction (Basics)
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

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. }