SlideShare a Scribd company logo
2
A pointer is a variable whose value is the address of another variable, i.e., direct address
of the memory location.
What is pointer ?
7866321
Pointer variable Normal variable
int *a int b
Address: 7865321 Address: 7866321
Most read
3
Pointers in C language is a variable that stores/points the address of another variable.
A Pointer in C is used to allocate memory dynamically i.e. at run time.
The pointer variable might be belonging to any of the data type such as int, float, char,
double, short etc.
Like any variable or constant, you must declare a pointer before using it to store any
variable address.
What is pointer ?
Most read
13
Reference operator (&) and Dereference operator (*)
& is called reference operator. It gives you the address of a variable.
Likewise, there is another operator that gets you the value from the address, it is called
a dereference operator (*).
Note: The * sign when declaring a pointer is not a dereference operator. It is just a
similar notation that creates a pointer.
Most read
Pointer in C
A pointer is a variable whose value is the address of another variable, i.e., direct address
of the memory location.
What is pointer ?
7866321
Pointer variable Normal variable
int *a int b
Address: 7865321 Address: 7866321
Pointers in C language is a variable that stores/points the address of another variable.
A Pointer in C is used to allocate memory dynamically i.e. at run time.
The pointer variable might be belonging to any of the data type such as int, float, char,
double, short etc.
Like any variable or constant, you must declare a pointer before using it to store any
variable address.
What is pointer ?
The general form of a pointer variable declaration is
What is pointer ?
type *var_name;
Take a look at some of the valid
pointer declarations −
int *ip; /* pointer to an integer */
double *dp; /* pointer to a double */
float *fp; /* pointer to a float */
char *ch /* pointer to a character */
There are a few important operations, in pointer
• (a) define a pointer variable,
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
• (b) assign the address of a variable to a pointer
ip = &var; /* store address of var in pointer variable*/
• (c) finally access the value at the address available in the pointer variable.
This is done by using unary operator * that returns the value of the variable
located at the address specified by its operand.
*ip /* access the value using the pointer */
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20;
int *ip;
ip = &var;
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip;
ip = &var;
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var;
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/
printf("Address stored in ip variable: %xn", ip ); /* address stored in pointer variable */
printf("Value of *ip variable: %dn", *ip ); /* access the value using the pointer */
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/
printf("Address stored in ip variable: %xn", ip ); /* address stored in pointer variable */
printf("Value of *ip variable: %dn", *ip ); /* access the value using the pointer */
return 0;
}
Reference operator (&) and Dereference operator (*)
& is called reference operator. It gives you the address of a variable.
Likewise, there is another operator that gets you the value from the address, it is called
a dereference operator (*).
Note: The * sign when declaring a pointer is not a dereference operator. It is just a
similar notation that creates a pointer.
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20;
int *ip; /* reference operator. */
ip = &var;
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip );
return 0;
}
How to Use Pointers?
#include <stdio.h>
int main () {
int var = 20;
int *ip; /* reference operator. */
ip = &var;
printf("Address of var variable: %xn", &var );
printf("Address stored in ip variable: %xn", ip );
printf("Value of *ip variable: %dn", *ip ); /* dereference operator */
return 0;
}

More Related Content

What's hot (20)

Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And References
verisan
 
C pointer
C pointerC pointer
C pointer
University of Potsdam
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
Sharad Dubey
 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Rajat Busheheri
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
P M Patil
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
C Programming : Pointers and Strings
C Programming : Pointers and StringsC Programming : Pointers and Strings
C Programming : Pointers and Strings
Selvaraj Seerangan
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
lavanya marichamy
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Kamal Acharya
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
yndaravind
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Viji B
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
gourav kottawar
 
Fundamentals of Pointers in C
Fundamentals of Pointers in CFundamentals of Pointers in C
Fundamentals of Pointers in C
ShivanshuVerma11
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Kamal Acharya
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And References
verisan
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
P M Patil
 
C Programming : Pointers and Strings
C Programming : Pointers and StringsC Programming : Pointers and Strings
C Programming : Pointers and Strings
Selvaraj Seerangan
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
lavanya marichamy
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Kamal Acharya
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Viji B
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
gourav kottawar
 
Fundamentals of Pointers in C
Fundamentals of Pointers in CFundamentals of Pointers in C
Fundamentals of Pointers in C
ShivanshuVerma11
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 

Viewers also liked (20)

Pointers in C
Pointers in CPointers in C
Pointers in C
guestdc3f16
 
C pointer basics
C pointer basicsC pointer basics
C pointer basics
Software Systems and Graphic Designs
 
Pointers
PointersPointers
Pointers
sarith divakar
 
Ponters
PontersPonters
Ponters
Mukund Trivedi
 
C++ Pointers
C++ PointersC++ Pointers
C++ Pointers
Chaand Sheikh
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
George Erfesoglou
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
Garrett Gutierrez
 
Pointers - DataStructures
Pointers - DataStructuresPointers - DataStructures
Pointers - DataStructures
Omair Imtiaz Ansari
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
Prabhu Govind
 
C Programming Language Part 5
C Programming Language Part 5C Programming Language Part 5
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
Rumman Ansari
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
Rumman Ansari
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
Rumman Ansari
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Agricultural Conversion Study Example
Agricultural Conversion Study ExampleAgricultural Conversion Study Example
Agricultural Conversion Study Example
CEQAplanner
 
Prospects from AMPLIFIRE
Prospects from AMPLIFIREProspects from AMPLIFIRE
Prospects from AMPLIFIRE
Future Internet Research and Experimentation - FIRE
 
Pointer in C
Pointer in CPointer in C
Pointer in C
Sonya Akter Rupa
 
Typecasting in c
Typecasting in cTypecasting in c
Typecasting in c
Tushar Shende
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Saket Pathak
 
Ad

Similar to Pointer in c program (20)

Pointer
PointerPointer
Pointer
DharmaKumariBhandari
 
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
SowmyaJyothi3
 
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
sudhakargeruganti
 
Algoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - PointersAlgoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - Pointers
martijnkuipersandebo
 
pointers CP Lecture.ppt
pointers CP Lecture.pptpointers CP Lecture.ppt
pointers CP Lecture.ppt
EC42ShaikhAmaan
 
Pointer in C
Pointer in CPointer in C
Pointer in C
baabtra.com - No. 1 supplier of quality freshers
 
4 Pointers.pptx
4 Pointers.pptx4 Pointers.pptx
4 Pointers.pptx
aarockiaabinsAPIICSE
 
Ponters
PontersPonters
Ponters
Anil Dutt
 
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
sajinis3
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
Pointers in c
Pointers in cPointers in c
Pointers in c
JeevanandhamSubraman
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
SwapnaliPawar27
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handlingMca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
Btech 1 pic u-5 pointer, structure ,union and intro to file handling
Btech 1 pic u-5 pointer, structure ,union and intro to file handlingBtech 1 pic u-5 pointer, structure ,union and intro to file handling
Btech 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.pptbtech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
chintuyadav19
 
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handlingBsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3
YOGESH SINGH
 
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Rai University
 
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
SowmyaJyothi3
 
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
sudhakargeruganti
 
Algoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - PointersAlgoritmos e Estruturas de Dados - Pointers
Algoritmos e Estruturas de Dados - Pointers
martijnkuipersandebo
 
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
sajinis3
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handlingMca 1 pic u-5 pointer, structure ,union and intro to file handling
Mca 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
Btech 1 pic u-5 pointer, structure ,union and intro to file handling
Btech 1 pic u-5 pointer, structure ,union and intro to file handlingBtech 1 pic u-5 pointer, structure ,union and intro to file handling
Btech 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.pptbtech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
btech-1picu-5pointerstructureunionandintrotofilehandling-150122010700-conver.ppt
chintuyadav19
 
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handlingBsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Bsc cs 1 pic u-5 pointer, structure ,union and intro to file handling
Rai University
 
VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3
YOGESH SINGH
 
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.1 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.1 pointer, structure ,union and intro to file handling
Rai University
 
Ad

More from Rumman Ansari (20)

Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best websiteJava Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
Rumman Ansari
 
servlet programming
servlet programmingservlet programming
servlet programming
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
Rumman Ansari
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
Rumman Ansari
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
Rumman Ansari
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Java Tutorial best websiteJava Tutorial best website
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
Rumman Ansari
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
Rumman Ansari
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
Rumman Ansari
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
Rumman Ansari
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
Rumman Ansari
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
Rumman Ansari
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
Rumman Ansari
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
Rumman Ansari
 

Recently uploaded (20)

Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
chemistry investigatory project for class 12
chemistry investigatory project for class 12chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank
Guru Nanak Technical Institutions
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible PavementsPavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Ppt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineeringPpt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineering
ravindrabodke
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdfHow Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
chemistry investigatory project for class 12
chemistry investigatory project for class 12chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible PavementsPavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Ppt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineeringPpt on the related on the solar power system for electric vehicle engineering
Ppt on the related on the solar power system for electric vehicle engineering
ravindrabodke
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdfHow Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagementoperationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 

Pointer in c program

  • 2. A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. What is pointer ? 7866321 Pointer variable Normal variable int *a int b Address: 7865321 Address: 7866321
  • 3. Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc. Like any variable or constant, you must declare a pointer before using it to store any variable address. What is pointer ?
  • 4. The general form of a pointer variable declaration is What is pointer ? type *var_name; Take a look at some of the valid pointer declarations − int *ip; /* pointer to an integer */ double *dp; /* pointer to a double */ float *fp; /* pointer to a float */ char *ch /* pointer to a character */
  • 5. There are a few important operations, in pointer • (a) define a pointer variable, int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ • (b) assign the address of a variable to a pointer ip = &var; /* store address of var in pointer variable*/ • (c) finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand. *ip /* access the value using the pointer */
  • 6. How to Use Pointers? #include <stdio.h> int main () { int var = 20; int *ip; ip = &var; printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 7. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; ip = &var; printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 8. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 9. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; /* store address of var in pointer variable*/ printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 10. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; /* store address of var in pointer variable*/ printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/ printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 11. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; /* store address of var in pointer variable*/ printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/ printf("Address stored in ip variable: %xn", ip ); /* address stored in pointer variable */ printf("Value of *ip variable: %dn", *ip ); /* access the value using the pointer */ return 0; }
  • 12. How to Use Pointers? #include <stdio.h> int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; /* store address of var in pointer variable*/ printf("Address of var variable: %xn", &var ); /* print the Address of var variable*/ printf("Address stored in ip variable: %xn", ip ); /* address stored in pointer variable */ printf("Value of *ip variable: %dn", *ip ); /* access the value using the pointer */ return 0; }
  • 13. Reference operator (&) and Dereference operator (*) & is called reference operator. It gives you the address of a variable. Likewise, there is another operator that gets you the value from the address, it is called a dereference operator (*). Note: The * sign when declaring a pointer is not a dereference operator. It is just a similar notation that creates a pointer.
  • 14. How to Use Pointers? #include <stdio.h> int main () { int var = 20; int *ip; /* reference operator. */ ip = &var; printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); return 0; }
  • 15. How to Use Pointers? #include <stdio.h> int main () { int var = 20; int *ip; /* reference operator. */ ip = &var; printf("Address of var variable: %xn", &var ); printf("Address stored in ip variable: %xn", ip ); printf("Value of *ip variable: %dn", *ip ); /* dereference operator */ return 0; }