SlideShare a Scribd company logo
UNIT
III
POINTERS AND STRING
TOPICS: POINTER
• MEMORY ACCESS AND POINTERS
• POINTER BASICS
• DECLARING
• INITIALIZING
• DEREFERENCING A POINTER
• PARAMETER PASSING MECHANISM
• OPERATIONS ON POINTER
MEMORY
ACCESS
Memory access refers to
the ability to read from or
write to specific locations
in the computer's memory.
The memory in a computer
is organized into a
sequence of bytes, each
with a unique address.
MEMORY ACCESS
• Every variable is a memory
location and every memory
location has its address defined
which can be accessed through
ampersand (&) operator, which
denotes an address in memory
Address of a:
0x7ffd7218d764
Address of b:
0x7ffd7218d760
Address of c:
0x7ffd7218d75f
#include <stdio.h>
int main()
{
int a = 10;
double b = 20.5;
char c = 'A';
printf("Address of a: %pn", &a);
printf("Address of b: %pn", &b);
printf("Address of c: %pn", &c);
return 0;
}
Variables
• Variables in C are named storage locations that hold values of a
specific data type.
• When you declare a variable, the compiler allocates memory to
store its value, and you can access that memory using the
variable's name.
int age = 25;
// Declaring an integer variable 'age' and assigning it a value
Pointer
• Pointers are variables that store memory addresses. They allow
direct access to the memory location they point to.
• Pointers are declared with a specific data type, indicating the
type of data stored at the memory location.
• Example, int a=10;
• int *ptr; // Declaration of an integer pointer
10
10
a
Location
Value
Name of the variable
80F Address of the location
Pointer
• Value 10 can be accessed by using the variable name or the
address 80F
• Memory address are simply numbers can be assigned to some
other variable.
• The variable that holds the memory address is called pointer
variable
10
10
a
80F
10
80F
ptr
82C
Pointer name
Address of the
pointer
Address
of a
Pointer
• Value 10 can be accessed by using the variable name or the
address 80F
• Memory address are simply numbers can be assigned to some
other variable.
• The variable that holds the memory address is called pointer
variable
10
10
a
80F
10
80F
ptr
82C
Pointer name
Address of the
pointer
Address
of a
Address of operator
• The address-of operator (&) is used to get the memory address
of a variable.
int age = 25;
int *ptr = &age; // Assigning the address of 'age' to the pointer
'ptr'
Dereferencing operator
• The dereference operator (*) is used to access the value stored
at a memory address pointed to by a pointer.
int age = 25;
int *ptr = &age;
printf("Value at the memory address pointed by ptr: %dn", *ptr);
• Sample Program 1
• Pointer declaration and initialization
• Sample Program 2
• Pointer Basics
Void pointer
• Pointer that is not associated with any data type.
• It can point to objects of any type but doesn't provide
information about the type of data it points to.
• Void pointer sample Program
• Syntax:
• Void *pointer name;
Null pointer
• A null pointer in C is a pointer that does not point to any
memory location.
• It is a special constant value (often represented as 0 or NULL)
that is assigned to a pointer variable to indicate that it does not
currently point to a valid memory address.
• Null pointer sample program
• Syntax:
• Int *p=NULL;
Parameter
passing
Pass by value
Pass by reference
Pass by value
• The value of the argument is passed to the function.
• Changes made to the parameter inside the function do not
affect the original value.
• Sample Pgm
#include <stdio.h>
void incrementByValue(int x) {
x++;
printf("Inside function: x = %dn", x);
}
int main() {
int num = 5;
printf("Before function call: num = %dn", num);
incrementByValue(num);
printf("After function call: num = %dn", num);
return 0;
}
Pass by reference
• The address of the argument is passed to the function using a
pointer.
• Changes made to the parameter inside the function affect the
original value.
• Sample Pgm
#include <stdio.h>
void incrementByReference(int *x) {
(*x)++;
printf("Inside function: *x = %dn", *x);
}
int main() {
int num = 5;
printf("Before function call: num = %dn", num);
incrementByReference(&num);
printf("After function call: num = %dn", num);
return 0;
}

More Related Content

Similar to Pointers

Pointers
PointersPointers
Pointers
Frijo Francis
 
l7-pointers.ppt
l7-pointers.pptl7-pointers.ppt
l7-pointers.ppt
ShivamChaturvedi67
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
rajatryadav22
 
Advance topics of C language
Advance  topics of C languageAdvance  topics of C language
Advance topics of C language
Mehwish Mehmood
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptx
sangeeta borde
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
Hemantha Kulathilake
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
SwapnaliPawar27
 
0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf
ssusere19c741
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
ArshiniGubbala3
 
Session 5
Session 5Session 5
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
sajinis3
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
tech4us
 
C
CC
Pointers and Array, pointer and String.pptx
Pointers and Array, pointer and String.pptxPointers and Array, pointer and String.pptx
Pointers and Array, pointer and String.pptx
Ananthi Palanisamy
 
Pointer in C
Pointer in CPointer in C
Pointer in C
bipchulabmki
 
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
 
Pointer
PointerPointer
Pointer
Fahuda E
 
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...
Jayanshu Gundaniya
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
presentation_pointers_1444076066_140676 (1).ppt
presentation_pointers_1444076066_140676 (1).pptpresentation_pointers_1444076066_140676 (1).ppt
presentation_pointers_1444076066_140676 (1).ppt
georgejustymirobi1
 

Similar to Pointers (20)

Pointers
PointersPointers
Pointers
 
l7-pointers.ppt
l7-pointers.pptl7-pointers.ppt
l7-pointers.ppt
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
Advance topics of C language
Advance  topics of C languageAdvance  topics of C language
Advance topics of C language
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptx
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf0-Slot11-12-Pointers.pdf
0-Slot11-12-Pointers.pdf
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Session 5
Session 5Session 5
Session 5
 
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
 
C
CC
C
 
Pointers and Array, pointer and String.pptx
Pointers and Array, pointer and String.pptxPointers and Array, pointer and String.pptx
Pointers and Array, pointer and String.pptx
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
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
 
Pointer
PointerPointer
Pointer
 
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...
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
presentation_pointers_1444076066_140676 (1).ppt
presentation_pointers_1444076066_140676 (1).pptpresentation_pointers_1444076066_140676 (1).ppt
presentation_pointers_1444076066_140676 (1).ppt
 

Recently uploaded

New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 

Recently uploaded (20)

New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 

Pointers

  • 2. TOPICS: POINTER • MEMORY ACCESS AND POINTERS • POINTER BASICS • DECLARING • INITIALIZING • DEREFERENCING A POINTER • PARAMETER PASSING MECHANISM • OPERATIONS ON POINTER
  • 3. MEMORY ACCESS Memory access refers to the ability to read from or write to specific locations in the computer's memory. The memory in a computer is organized into a sequence of bytes, each with a unique address.
  • 4. MEMORY ACCESS • Every variable is a memory location and every memory location has its address defined which can be accessed through ampersand (&) operator, which denotes an address in memory
  • 5.
  • 6. Address of a: 0x7ffd7218d764 Address of b: 0x7ffd7218d760 Address of c: 0x7ffd7218d75f #include <stdio.h> int main() { int a = 10; double b = 20.5; char c = 'A'; printf("Address of a: %pn", &a); printf("Address of b: %pn", &b); printf("Address of c: %pn", &c); return 0; }
  • 7. Variables • Variables in C are named storage locations that hold values of a specific data type. • When you declare a variable, the compiler allocates memory to store its value, and you can access that memory using the variable's name. int age = 25; // Declaring an integer variable 'age' and assigning it a value
  • 8. Pointer • Pointers are variables that store memory addresses. They allow direct access to the memory location they point to. • Pointers are declared with a specific data type, indicating the type of data stored at the memory location. • Example, int a=10; • int *ptr; // Declaration of an integer pointer 10 10 a Location Value Name of the variable 80F Address of the location
  • 9. Pointer • Value 10 can be accessed by using the variable name or the address 80F • Memory address are simply numbers can be assigned to some other variable. • The variable that holds the memory address is called pointer variable 10 10 a 80F 10 80F ptr 82C Pointer name Address of the pointer Address of a
  • 10. Pointer • Value 10 can be accessed by using the variable name or the address 80F • Memory address are simply numbers can be assigned to some other variable. • The variable that holds the memory address is called pointer variable 10 10 a 80F 10 80F ptr 82C Pointer name Address of the pointer Address of a
  • 11. Address of operator • The address-of operator (&) is used to get the memory address of a variable. int age = 25; int *ptr = &age; // Assigning the address of 'age' to the pointer 'ptr'
  • 12. Dereferencing operator • The dereference operator (*) is used to access the value stored at a memory address pointed to by a pointer. int age = 25; int *ptr = &age; printf("Value at the memory address pointed by ptr: %dn", *ptr);
  • 13. • Sample Program 1 • Pointer declaration and initialization • Sample Program 2 • Pointer Basics
  • 14. Void pointer • Pointer that is not associated with any data type. • It can point to objects of any type but doesn't provide information about the type of data it points to. • Void pointer sample Program • Syntax: • Void *pointer name;
  • 15. Null pointer • A null pointer in C is a pointer that does not point to any memory location. • It is a special constant value (often represented as 0 or NULL) that is assigned to a pointer variable to indicate that it does not currently point to a valid memory address. • Null pointer sample program • Syntax: • Int *p=NULL;
  • 17. Pass by value • The value of the argument is passed to the function. • Changes made to the parameter inside the function do not affect the original value. • Sample Pgm
  • 18. #include <stdio.h> void incrementByValue(int x) { x++; printf("Inside function: x = %dn", x); } int main() { int num = 5; printf("Before function call: num = %dn", num); incrementByValue(num); printf("After function call: num = %dn", num); return 0; }
  • 19. Pass by reference • The address of the argument is passed to the function using a pointer. • Changes made to the parameter inside the function affect the original value. • Sample Pgm
  • 20. #include <stdio.h> void incrementByReference(int *x) { (*x)++; printf("Inside function: *x = %dn", *x); } int main() { int num = 5; printf("Before function call: num = %dn", num); incrementByReference(&num); printf("After function call: num = %dn", num); return 0; }