SlideShare a Scribd company logo
Pointer
A pointer is a variable that stores memory address. Like all
other variables ,it also has a name, has to be declared and
occupies some space in memory. It is called pointer
because it points to a particular location in memory (by
storing the address of that location).
The expression having (*) operator is known as pointer
expression. Pointer is the variable that points to the
memory location of the next variable. So, we have to assign
address of a variable to the pointer variable.
Int a=5;
Int *p1=&a;
If we put *before p1, then, we can access the variable whose
address is stored in p1. since p1 contains the address of
variable a, we can access the variable a by writing *p1.
What are Pointers?
Pointers are different from other normal
variables. While other normal variables
store values, pointers are special variables
that can hold the address of a variable.
Since they store memory address of a
variable, the pointers are very commonly
said to “point to variables”.
Pointer
• A pointer is a variable which holds the address
of the storage location value for another given
variable.
• C provides two operators & and * which allow
pointers to be used in many versatile ways.
*:- is the value of address eg.*a
&:- is the address of variable eg. &a
*(&a):- we are using the value which is inside of
the address
pointer arithmetic operations are
allowed?
• A pointer can be incremented (++) or decremented (--)
• An integer may be added to a pointer (+ or +=)
• An integer may be subtracted from a pointer (- or -=)
• One pointer may be subtracted from another
In c programming every variable keeps two type of value.
1. Contain of variable or value of variable.
2. Address of variable where it has stored in the memory.
(1) Meaning of following simple pointer declaration and definition:
int a=5;
int * ptr;
ptr=&a;
Explanation:
About variable a:
1. Name of variable : a
2. Value of variable which it keeps: 5
3. Address where it has stored in memory : 1025 (assume)
About variable ptr:
4. Name of variable : ptr
5. Value of variable which it keeps: 1025
6. Address where it has stored in memory : 5000 (assume)
A normal variable ‘var’ has a memory address of 1001 and holds a
value 50.
A pointer variable has its own address 2047 but stores 1001,
which is the address of the variable ‘var’
Another example:
Int I, *j, **K;
Here I is dinary int ,J is a pointer to an int , whereas K is a pointer
to an integer pointer
3 65524 65522
i
65524
j
65522
65520
k
For example
a ) valid example
Int *p;
Int num;
P=#
b) Invalid example
Int *p;
Float num;
P=# /*as pointer variable p can not store address of float variable*/
Data type
Integer
Unsigned integer
Octal
Hexadecimal
Float simple
Float exponential
Character
string
Conversion Charater
D
U
O
X
F
E
C
S
#include <stdio.h>
#include <conio.h>
void main( )
{
int u = 36;
int *pu; /*pionter to an integer*/
clrscr();
pu=&u; /*assign address of u to pu*/
printf("nu=%d &u=%x *pu=%d",u,&u,*pu);
getch();
}
/* Illustration of pointer data type */
#include <stdio.h>
#include <conio.h>
void main( )
{
int u = 36;
int v;
int *pu; /* pointer to an integer*/
int *pv; /* pointer to an integer*/
clrscr();
pu = &u; /* assign address of u to pu */
v = *pu; /* assign address of u to v */
pv = &v; /* assign address of v to pv */
printf("nu = %d n&u = %x npu = %x n*pu = %d", u,&u, pu, *pu);
printf("nnv = %d n&v = %xn pv = %x n*pv = %d", v, &v, pv, *pv);
getch();
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,sum, *ptra,*ptrb;
a=20;
b=10;
ptra =&a;
ptrb=&b;
sum=*ptra+*ptrb;
printf("sum=%d",sum);
getch();
}
1. WAP to add value stored in two variable using pointer

More Related Content

PPTX
Pointers in C Language
PPTX
Presentation on pointer.
PPT
C pointers
PDF
Pointers
PPTX
Pointer in c program
PPTX
ppt on pointers
PDF
C Pointers
PDF
Pointer in c++ part1
Pointers in C Language
Presentation on pointer.
C pointers
Pointers
Pointer in c program
ppt on pointers
C Pointers
Pointer in c++ part1

What's hot (20)

PDF
Data structure week 2
PPTX
Pointer in C
PDF
Pointers_c
PPTX
Pointers in C
PDF
Pointers in C
PPT
PDF
Types of pointer in C
PPTX
Used of Pointer in C++ Programming
PPT
C++ Pointers And References
PPTX
Fundamentals of Pointers in C
PPTX
Pointer in c
PPT
Pointers in c
PPT
C++ functions
PPTX
Unit 8. Pointers
PPTX
C programming - Pointers
PPT
Pointers (Pp Tminimizer)
PPTX
Pointer in c
PPT
Pointers in C
PDF
Data structure week 3
PPT
Introduction to pointers and memory management in C
Data structure week 2
Pointer in C
Pointers_c
Pointers in C
Pointers in C
Types of pointer in C
Used of Pointer in C++ Programming
C++ Pointers And References
Fundamentals of Pointers in C
Pointer in c
Pointers in c
C++ functions
Unit 8. Pointers
C programming - Pointers
Pointers (Pp Tminimizer)
Pointer in c
Pointers in C
Data structure week 3
Introduction to pointers and memory management in C
Ad

Similar to Pointer (20)

PPTX
PPS-POINTERS.pptx
PPT
SPC Unit 3
PDF
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
PDF
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
PPTX
Pointers in C
PDF
PSPC--UNIT-5.pdf
PPTX
INTRODUCTION TO POINTER IN c++ AND POLYMORPHISM
PPT
Lect 9(pointers) Zaheer Abbas
PPT
Lect 8(pointers) Zaheer Abbas
PPT
pointers (1).ppt
PPTX
Unit-I Pointer Data structure.pptx
PPTX
Lecture 7_Pointer.pptx FOR EDUCATIONAL PURPOSE
PPTX
COM1407: Working with Pointers
PPTX
pointers.pptx
PPT
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
PPTX
20.C++Pointer.pptx
PPTX
POINTERS IN C
PPTX
pointers.pptx
PPTX
Pointers
PDF
Chapter 13.1.8
PPS-POINTERS.pptx
SPC Unit 3
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
Pointers in C
PSPC--UNIT-5.pdf
INTRODUCTION TO POINTER IN c++ AND POLYMORPHISM
Lect 9(pointers) Zaheer Abbas
Lect 8(pointers) Zaheer Abbas
pointers (1).ppt
Unit-I Pointer Data structure.pptx
Lecture 7_Pointer.pptx FOR EDUCATIONAL PURPOSE
COM1407: Working with Pointers
pointers.pptx
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
20.C++Pointer.pptx
POINTERS IN C
pointers.pptx
Pointers
Chapter 13.1.8
Ad

More from DharmaKumariBhandari (7)

PPTX
De Mornan Theory, Boolean Algebra, 7 logical get, truth table,
PDF
Loop's definition and practical code in C programming
PDF
PDF
C programme presentation
PPTX
social prospective in Education
De Mornan Theory, Boolean Algebra, 7 logical get, truth table,
Loop's definition and practical code in C programming
C programme presentation
social prospective in Education

Recently uploaded (20)

PDF
⚡ Prepping for grid failure_ 6 Must-Haves to Survive Blackout!.pdf
PPTX
Life Skills Education - Introduction - 1
PDF
relational self of self improvements etc
PPTX
chuong-2-nhung-hinh-thuc-tu-duy-20250711081647-e-20250718055609-e.pptx
PDF
Want to Fly Like an Eagle - Leave the Chickens Behind.pdf
PDF
Quiet Wins: Why the Silent Fish Survives.pdf
PDF
technical writing on emotional quotient ppt
PPTX
UNIVERSAL HUMAN VALUES for NEP student .pptx
PDF
OneRead_20250728_1807.pdfbdjsajaajjajajsjsj
PPTX
A portfolio Template for Interior Designer
PDF
Dominate Her Mind – Make Women Chase, Lust, & Submit
PPTX
Arabic Grammar with related Qurani ayat .pptx
PDF
Lesson 4 Education for Better Work. Evaluate your training options.
PDF
How Long Does It Take to Quit Vaping.pdf
DOCX
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
PPTX
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx
PPT
Lesson From Geese! Understanding Teamwork
PPTX
Unlocking Success Through the Relentless Power of Grit
PDF
Psychology and Work Today 10th Edition by Duane Schultz Test Bank.pdf
PDF
Anxiety Awareness Journal One Week Preview
⚡ Prepping for grid failure_ 6 Must-Haves to Survive Blackout!.pdf
Life Skills Education - Introduction - 1
relational self of self improvements etc
chuong-2-nhung-hinh-thuc-tu-duy-20250711081647-e-20250718055609-e.pptx
Want to Fly Like an Eagle - Leave the Chickens Behind.pdf
Quiet Wins: Why the Silent Fish Survives.pdf
technical writing on emotional quotient ppt
UNIVERSAL HUMAN VALUES for NEP student .pptx
OneRead_20250728_1807.pdfbdjsajaajjajajsjsj
A portfolio Template for Interior Designer
Dominate Her Mind – Make Women Chase, Lust, & Submit
Arabic Grammar with related Qurani ayat .pptx
Lesson 4 Education for Better Work. Evaluate your training options.
How Long Does It Take to Quit Vaping.pdf
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx
Lesson From Geese! Understanding Teamwork
Unlocking Success Through the Relentless Power of Grit
Psychology and Work Today 10th Edition by Duane Schultz Test Bank.pdf
Anxiety Awareness Journal One Week Preview

Pointer

  • 1. Pointer A pointer is a variable that stores memory address. Like all other variables ,it also has a name, has to be declared and occupies some space in memory. It is called pointer because it points to a particular location in memory (by storing the address of that location). The expression having (*) operator is known as pointer expression. Pointer is the variable that points to the memory location of the next variable. So, we have to assign address of a variable to the pointer variable. Int a=5; Int *p1=&a; If we put *before p1, then, we can access the variable whose address is stored in p1. since p1 contains the address of variable a, we can access the variable a by writing *p1.
  • 2. What are Pointers? Pointers are different from other normal variables. While other normal variables store values, pointers are special variables that can hold the address of a variable. Since they store memory address of a variable, the pointers are very commonly said to “point to variables”.
  • 3. Pointer • A pointer is a variable which holds the address of the storage location value for another given variable. • C provides two operators & and * which allow pointers to be used in many versatile ways. *:- is the value of address eg.*a &:- is the address of variable eg. &a *(&a):- we are using the value which is inside of the address
  • 4. pointer arithmetic operations are allowed? • A pointer can be incremented (++) or decremented (--) • An integer may be added to a pointer (+ or +=) • An integer may be subtracted from a pointer (- or -=) • One pointer may be subtracted from another
  • 5. In c programming every variable keeps two type of value. 1. Contain of variable or value of variable. 2. Address of variable where it has stored in the memory. (1) Meaning of following simple pointer declaration and definition: int a=5; int * ptr; ptr=&a; Explanation: About variable a: 1. Name of variable : a 2. Value of variable which it keeps: 5 3. Address where it has stored in memory : 1025 (assume) About variable ptr: 4. Name of variable : ptr 5. Value of variable which it keeps: 1025 6. Address where it has stored in memory : 5000 (assume)
  • 6. A normal variable ‘var’ has a memory address of 1001 and holds a value 50. A pointer variable has its own address 2047 but stores 1001, which is the address of the variable ‘var’
  • 7. Another example: Int I, *j, **K; Here I is dinary int ,J is a pointer to an int , whereas K is a pointer to an integer pointer 3 65524 65522 i 65524 j 65522 65520 k
  • 8. For example a ) valid example Int *p; Int num; P=&num; b) Invalid example Int *p; Float num; P=&num; /*as pointer variable p can not store address of float variable*/
  • 9. Data type Integer Unsigned integer Octal Hexadecimal Float simple Float exponential Character string Conversion Charater D U O X F E C S
  • 10. #include <stdio.h> #include <conio.h> void main( ) { int u = 36; int *pu; /*pionter to an integer*/ clrscr(); pu=&u; /*assign address of u to pu*/ printf("nu=%d &u=%x *pu=%d",u,&u,*pu); getch(); }
  • 11. /* Illustration of pointer data type */ #include <stdio.h> #include <conio.h> void main( ) { int u = 36; int v; int *pu; /* pointer to an integer*/ int *pv; /* pointer to an integer*/ clrscr(); pu = &u; /* assign address of u to pu */ v = *pu; /* assign address of u to v */ pv = &v; /* assign address of v to pv */ printf("nu = %d n&u = %x npu = %x n*pu = %d", u,&u, pu, *pu); printf("nnv = %d n&v = %xn pv = %x n*pv = %d", v, &v, pv, *pv); getch();
  • 12. #include <stdio.h> #include <conio.h> void main() { int a,b,sum, *ptra,*ptrb; a=20; b=10; ptra =&a; ptrb=&b; sum=*ptra+*ptrb; printf("sum=%d",sum); getch(); } 1. WAP to add value stored in two variable using pointer