SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
BIRLA INSTITUTE OF
TECHNOLOGY
TOPIC :- POINTERS BASICS, CONSTANT
POINTERS AND POINTERS TO CONSTANT
DIVYANSH
PARMARTHI
MCA/25016/18
SHRADDHA
POINTERS
• A pointer is a variable that points a address of a variable.
• A pointer is declared using the * operator before an identifier.
 Declaration of Pointer variables :
type *pointer_name;
where type is the type of data pointed to
For example :- int *numberPointer;
ADDRESS (&) OPERATOR
 Pointer address operator is denoted by ‘&’ symbol
 The & is a unary operator that returns the memory address of its
operand.
Example :
&n - It gives an address on variable n
DEREFERENCING OPERATOR (*)
 We can access to the value stored in the variable pointed to by
using the dereferencing operator (*)
Syntax: *PointerVariable
Example:
int V = 101;
int *P = &V;
POINTERS TO POINTERS
 A pointer to a pointer is a chain of pointers.
 In pointer to a pointer, the first pointer contains the address of the
second pointer, which points to the location that contains the actual
value.
Pointer Pointer Variable
Address Address Value
Declaration of pointer to a pointer :
int **ptr;
For example :
// local declaration
int a;
int *p;
int **q;
// Statment
a=58;
p=&a;
q=&p;
cout << a << “ “ <<endl;
cout << *p << “ “ <<endl;
cout<< **q << “ “ <<endl;
OUTPUT
58
58
58
POINTERS AS PARAMETERS
 To make changes to a variable that exist after a function ends, we
pass the address of the variable to the function
For example :
#include<iostream.h>
void Indirectswap(char *ptr1, char *ptr2)
{
char c = *ptr1;
*ptr1 = *ptr2;
*ptr2 = c;
}
int main()
{
char a = ‘y’;
char b = ‘n’;
Indirectswap(&a,&b);
cout<< a << “and”<< b << endl;
return 0;
}
OUTPUT
n and y
CONSTANT POINTERS AND
POINTERS TO CONSTANT
BY :-
SHRADDHA
MALVIYA
Constant pointer
 Constant pointer cannot be modified.
 Modification in integer to which it points to it is allowed.
 Syntax:
int n1=20;
int *const ptr=&n1; //Declare constant
Example of constant pointer
Output
Pointer to constant
 Pointer to constant object is called as pointer to constant object.
Syntax:
int n=30;
const int *ptr=&n;
“const int” means integer constant.
We cannot change value of integer.
We can change address of such pointer so that it will point to new
memory allocation
Example of pointer to constant
Output
Difference
Constant pointer Pointer to constant
Pointer can be incremented. Pointer is not incremented.
Constant pointer is pointing to data object. Pointer is pointing to constant data object.t
Declaration :int * const ptr; Declaration: const int *ptr;
THANK
YOU

More Related Content

PPT
Operators in C Programming
PDF
Javascript Basic
PPTX
Constructors in java
PDF
Java programming-examples
PPTX
Java 101 Intro to Java Programming - Exercises
PPTX
Java Method, Static Block
PPTX
Java input
PDF
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Operators in C Programming
Javascript Basic
Constructors in java
Java programming-examples
Java 101 Intro to Java Programming - Exercises
Java Method, Static Block
Java input
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...

What's hot (20)

PDF
BOOK SHOP SYSTEM Project in Python
PPT
Java: Objects and Object References
PPT
Java Script Object Notation (JSON)
PPTX
Java static keyword
PPTX
Super Keyword in Java.pptx
PPT
Javascript
DOC
Electricitybillsystemreport
PPSX
Data Types & Variables in JAVA
PPT
Array in Java
PDF
PPTX
Assignment
PPTX
Presentation on cumulative record (non testing technique
PDF
Population Education.pdf
PPTX
Aristotle contribution.pptx
PPTX
Access specifier
PPTX
Java - Collections framework
PDF
JavaScript - Chapter 6 - Basic Functions
PPTX
Array in c++
PPTX
Java string handling
BOOK SHOP SYSTEM Project in Python
Java: Objects and Object References
Java Script Object Notation (JSON)
Java static keyword
Super Keyword in Java.pptx
Javascript
Electricitybillsystemreport
Data Types & Variables in JAVA
Array in Java
Assignment
Presentation on cumulative record (non testing technique
Population Education.pdf
Aristotle contribution.pptx
Access specifier
Java - Collections framework
JavaScript - Chapter 6 - Basic Functions
Array in c++
Java string handling
Ad

Similar to Pointer Basics,Constant Pointers & Pointer to Constant. (20)

PPTX
Pointers in c++
PPTX
Object Oriented Programming using C++: Ch10 Pointers.pptx
PPT
Pointer
PPT
Pointers
PDF
Chapter 2 - Introduction to Pointer Variables - Student.pdf
PPTX
Used of Pointer in C++ Programming
ODP
Pointers in c++ by minal
PPTX
pointers,virtual functions and polymorphism
PDF
Object Oriented Programming using C++ - Part 4
PPTX
INTRODUCTION TO POINTER IN c++ AND POLYMORPHISM
PDF
Chapter 5 (Part I) - Pointers.pdf
PPTX
Pointer in C++
PPT
Computer Programming (C++)Pointers and Arrays
PPTX
COM1407: Working with Pointers
PPT
Pointers
PPTX
Pointers in c++
PDF
Pointers by: Professor Lili Saghafi
PPT
C/C++ Pointers explanationwith different examples
PPT
Pointers_in_c.pptfffgfggdggffffrreeeggttr
PPT
Lect 7 - 8 Pointers.pptffffffdfgfffddddg
Pointers in c++
Object Oriented Programming using C++: Ch10 Pointers.pptx
Pointer
Pointers
Chapter 2 - Introduction to Pointer Variables - Student.pdf
Used of Pointer in C++ Programming
Pointers in c++ by minal
pointers,virtual functions and polymorphism
Object Oriented Programming using C++ - Part 4
INTRODUCTION TO POINTER IN c++ AND POLYMORPHISM
Chapter 5 (Part I) - Pointers.pdf
Pointer in C++
Computer Programming (C++)Pointers and Arrays
COM1407: Working with Pointers
Pointers
Pointers in c++
Pointers by: Professor Lili Saghafi
C/C++ Pointers explanationwith different examples
Pointers_in_c.pptfffgfggdggffffrreeeggttr
Lect 7 - 8 Pointers.pptffffffdfgfffddddg
Ad

More from Meghaj Mallick (20)

PPT
24 partial-orderings
PPTX
PORTFOLIO BY USING HTML & CSS
PPTX
Introduction to Software Testing
PPTX
Introduction to System Programming
PPTX
MACRO ASSEBLER
PPTX
Icons, Image & Multimedia
PPTX
Project Tracking & SPC
PPTX
Peephole Optimization
PPTX
Routing in MANET
PPTX
Macro assembler
PPTX
Architecture and security in Vanet PPT
PPTX
Design Model & User Interface Design in Software Engineering
PPTX
Text Mining of Twitter in Data Mining
PPTX
DFS & BFS in Computer Algorithm
PPTX
Software Development Method
PPTX
Secant method in Numerical & Statistical Method
PPTX
Motivation in Organization
PPTX
Communication Skill
PPT
Partial-Orderings in Discrete Mathematics
PPTX
Hashing In Data Structure
24 partial-orderings
PORTFOLIO BY USING HTML & CSS
Introduction to Software Testing
Introduction to System Programming
MACRO ASSEBLER
Icons, Image & Multimedia
Project Tracking & SPC
Peephole Optimization
Routing in MANET
Macro assembler
Architecture and security in Vanet PPT
Design Model & User Interface Design in Software Engineering
Text Mining of Twitter in Data Mining
DFS & BFS in Computer Algorithm
Software Development Method
Secant method in Numerical & Statistical Method
Motivation in Organization
Communication Skill
Partial-Orderings in Discrete Mathematics
Hashing In Data Structure

Recently uploaded (20)

PPTX
Self management and self evaluation presentation
PPTX
Learning-Plan-5-Policies-and-Practices.pptx
PPTX
Tour Presentation Educational Activity.pptx
PPTX
The spiral of silence is a theory in communication and political science that...
PPTX
nose tajweed for the arabic alphabets for the responsive
PPTX
Intro to ISO 9001 2015.pptx wareness raising
PPTX
_ISO_Presentation_ISO 9001 and 45001.pptx
DOC
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
PPTX
Understanding-Communication-Berlos-S-M-C-R-Model.pptx
PPTX
2025-08-10 Joseph 02 (shared slides).pptx
PPTX
fundraisepro pitch deck elegant and modern
PDF
Why Top Brands Trust Enuncia Global for Language Solutions.pdf
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PDF
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
PDF
Swiggy’s Playbook: UX, Logistics & Monetization
PPTX
An Unlikely Response 08 10 2025.pptx
PDF
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
PPTX
Impressionism_PostImpressionism_Presentation.pptx
PPTX
Relationship Management Presentation In Banking.pptx
PPTX
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
Self management and self evaluation presentation
Learning-Plan-5-Policies-and-Practices.pptx
Tour Presentation Educational Activity.pptx
The spiral of silence is a theory in communication and political science that...
nose tajweed for the arabic alphabets for the responsive
Intro to ISO 9001 2015.pptx wareness raising
_ISO_Presentation_ISO 9001 and 45001.pptx
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
Understanding-Communication-Berlos-S-M-C-R-Model.pptx
2025-08-10 Joseph 02 (shared slides).pptx
fundraisepro pitch deck elegant and modern
Why Top Brands Trust Enuncia Global for Language Solutions.pdf
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
Swiggy’s Playbook: UX, Logistics & Monetization
An Unlikely Response 08 10 2025.pptx
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
Impressionism_PostImpressionism_Presentation.pptx
Relationship Management Presentation In Banking.pptx
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC

Pointer Basics,Constant Pointers & Pointer to Constant.

  • 1. BIRLA INSTITUTE OF TECHNOLOGY TOPIC :- POINTERS BASICS, CONSTANT POINTERS AND POINTERS TO CONSTANT DIVYANSH PARMARTHI MCA/25016/18 SHRADDHA
  • 2. POINTERS • A pointer is a variable that points a address of a variable. • A pointer is declared using the * operator before an identifier.
  • 3.  Declaration of Pointer variables : type *pointer_name; where type is the type of data pointed to For example :- int *numberPointer;
  • 4. ADDRESS (&) OPERATOR  Pointer address operator is denoted by ‘&’ symbol  The & is a unary operator that returns the memory address of its operand. Example : &n - It gives an address on variable n
  • 5. DEREFERENCING OPERATOR (*)  We can access to the value stored in the variable pointed to by using the dereferencing operator (*) Syntax: *PointerVariable Example: int V = 101; int *P = &V;
  • 6. POINTERS TO POINTERS  A pointer to a pointer is a chain of pointers.  In pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value. Pointer Pointer Variable Address Address Value
  • 7. Declaration of pointer to a pointer : int **ptr; For example : // local declaration int a; int *p; int **q; // Statment a=58; p=&a; q=&p;
  • 8. cout << a << “ “ <<endl; cout << *p << “ “ <<endl; cout<< **q << “ “ <<endl; OUTPUT 58 58 58
  • 9. POINTERS AS PARAMETERS  To make changes to a variable that exist after a function ends, we pass the address of the variable to the function For example : #include<iostream.h> void Indirectswap(char *ptr1, char *ptr2) { char c = *ptr1; *ptr1 = *ptr2; *ptr2 = c; }
  • 10. int main() { char a = ‘y’; char b = ‘n’; Indirectswap(&a,&b); cout<< a << “and”<< b << endl; return 0; } OUTPUT n and y
  • 11. CONSTANT POINTERS AND POINTERS TO CONSTANT BY :- SHRADDHA MALVIYA
  • 12. Constant pointer  Constant pointer cannot be modified.  Modification in integer to which it points to it is allowed.  Syntax: int n1=20; int *const ptr=&n1; //Declare constant
  • 15. Pointer to constant  Pointer to constant object is called as pointer to constant object. Syntax: int n=30; const int *ptr=&n; “const int” means integer constant. We cannot change value of integer. We can change address of such pointer so that it will point to new memory allocation
  • 16. Example of pointer to constant
  • 18. Difference Constant pointer Pointer to constant Pointer can be incremented. Pointer is not incremented. Constant pointer is pointing to data object. Pointer is pointing to constant data object.t Declaration :int * const ptr; Declaration: const int *ptr;