SlideShare a Scribd company logo

Types of function call

The ppt describes usage of functions in c language. Showing basic use of function and determining the differences between function call by value and function call by reference using pointer. It also includes valid use in swapping two numbers in c along with different outputs. Overall its a basic note for c language.

1 of 14
Download to read offline
Function Call
by
Value & Reference
By: Arijit Dhali
Contents
2
User Defined Function
Common Method of Swapping
Integers
Call by Value
Call by Reference
Differences
Conclusion
User Defined Function
A user-defined function is a function provided by the
user of a program or environment, in a context where
the usual assumption is that functions are built into
the program or environment.
Syntax:
return_type function_name (parameter list)
{
Function Body
return statement;
}
3
Common Method of Swapping Two Integers
4
#include<stdio.h>
main()
{
int x, y, z;
printf (“n Enter the value of x: ");
scanf ("%d", &x);
printf (“n Enter the value of y: ");
scanf ("%d", &y);
z = x;
x = y;
y = z;
printf ( "n After swap : x = %d, y = %d n", x, y);
return 0;
}
Using Third Variable
Source Code:
Storing Value
Storing Value
Swap using 3rd
Variable
Declaring Variable
5
Output:
Values Get Swapped
6
Call by Value
The call by value method of passing argument to a function, copies
the actual value of an argument into the formal parameter of the
function. In this case, changed made to parameter inside the function
had no effect on argument.
Ad

Recommended

More Related Content

What's hot

C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointersSamiksha Pun
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 

What's hot (20)

Functions in C
Functions in CFunctions in C
Functions in C
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Function in C program
Function in C programFunction in C program
Function in C program
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Function
FunctionFunction
Function
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Function in c program
Function in c programFunction in c program
Function in c program
 

Similar to Types of function call

Similar to Types of function call (20)

Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
chapter-7 slide.pptx
chapter-7 slide.pptxchapter-7 slide.pptx
chapter-7 slide.pptx
 
Function in c
Function in cFunction in c
Function in c
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Unit 4 (1)
Unit 4 (1)Unit 4 (1)
Unit 4 (1)
 
Array Cont
Array ContArray Cont
Array Cont
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Function in c
Function in cFunction in c
Function in c
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
 
Functions in C++.pdf
Functions in C++.pdfFunctions in C++.pdf
Functions in C++.pdf
 
C function
C functionC function
C function
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
cp Module4(1)
cp Module4(1)cp Module4(1)
cp Module4(1)
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 
User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in C
 
UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
 
C programs
C programsC programs
C programs
 

More from ArijitDhali

Signal Constellation, Geometric Interpretation of Signals
Signal Constellation,  Geometric Interpretation of  SignalsSignal Constellation,  Geometric Interpretation of  Signals
Signal Constellation, Geometric Interpretation of SignalsArijitDhali
 
Stack Queue SubRoutine
Stack Queue SubRoutineStack Queue SubRoutine
Stack Queue SubRoutineArijitDhali
 
Overviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfOverviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfArijitDhali
 
Motorola 68020.pdf
Motorola 68020.pdfMotorola 68020.pdf
Motorola 68020.pdfArijitDhali
 
Stereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfStereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfArijitDhali
 
Active Filters.pdf
Active Filters.pdfActive Filters.pdf
Active Filters.pdfArijitDhali
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfArijitDhali
 
Celebrity Problem.pdf
Celebrity Problem.pdfCelebrity Problem.pdf
Celebrity Problem.pdfArijitDhali
 
Biodiversity Hotspots in India
Biodiversity Hotspots in IndiaBiodiversity Hotspots in India
Biodiversity Hotspots in IndiaArijitDhali
 
LTI Systems - With/Without Memory
LTI Systems - With/Without MemoryLTI Systems - With/Without Memory
LTI Systems - With/Without MemoryArijitDhali
 
RLC Series Resonance
RLC Series ResonanceRLC Series Resonance
RLC Series ResonanceArijitDhali
 
Bivariate Discrete Distribution
Bivariate Discrete DistributionBivariate Discrete Distribution
Bivariate Discrete DistributionArijitDhali
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmArijitDhali
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional ProbabilityArijitDhali
 
Isomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexIsomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexArijitDhali
 
Space Solar Power
Space Solar PowerSpace Solar Power
Space Solar PowerArijitDhali
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationArijitDhali
 
Diffraction interference
Diffraction interferenceDiffraction interference
Diffraction interferenceArijitDhali
 

More from ArijitDhali (20)

Signal Constellation, Geometric Interpretation of Signals
Signal Constellation,  Geometric Interpretation of  SignalsSignal Constellation,  Geometric Interpretation of  Signals
Signal Constellation, Geometric Interpretation of Signals
 
Stack Queue SubRoutine
Stack Queue SubRoutineStack Queue SubRoutine
Stack Queue SubRoutine
 
Overviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfOverviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdf
 
Motorola 68020.pdf
Motorola 68020.pdfMotorola 68020.pdf
Motorola 68020.pdf
 
Stereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfStereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdf
 
Active Filters.pdf
Active Filters.pdfActive Filters.pdf
Active Filters.pdf
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdf
 
Celebrity Problem.pdf
Celebrity Problem.pdfCelebrity Problem.pdf
Celebrity Problem.pdf
 
Biodiversity Hotspots in India
Biodiversity Hotspots in IndiaBiodiversity Hotspots in India
Biodiversity Hotspots in India
 
LTI Systems - With/Without Memory
LTI Systems - With/Without MemoryLTI Systems - With/Without Memory
LTI Systems - With/Without Memory
 
RLC Series Resonance
RLC Series ResonanceRLC Series Resonance
RLC Series Resonance
 
Bivariate Discrete Distribution
Bivariate Discrete DistributionBivariate Discrete Distribution
Bivariate Discrete Distribution
 
Solar Cell
Solar CellSolar Cell
Solar Cell
 
Barcode Decoder
Barcode DecoderBarcode Decoder
Barcode Decoder
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional Probability
 
Isomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexIsomerism of Transition Metal Complex
Isomerism of Transition Metal Complex
 
Space Solar Power
Space Solar PowerSpace Solar Power
Space Solar Power
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's Equation
 
Diffraction interference
Diffraction interferenceDiffraction interference
Diffraction interference
 

Recently uploaded

20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt
20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt
20CE501PE – INDUSTRIAL WASTE MANAGEMENT.pptMohanumar S
 
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...GauravBhartie
 
chap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignchap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignteddymebratie
 
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdfDr. Shivashankar
 
Series of training sessions by our experts for you to provide necessary insig...
Series of training sessions by our experts for you to provide necessary insig...Series of training sessions by our experts for you to provide necessary insig...
Series of training sessions by our experts for you to provide necessary insig...AshishChanchal1
 
Get start with Machine Learning and Vertexai
Get start with Machine Learning and VertexaiGet start with Machine Learning and Vertexai
Get start with Machine Learning and VertexaiAshishChanchal1
 
biofilm fouling of the membrane present in aquaculture
biofilm fouling of the membrane present in aquaculturebiofilm fouling of the membrane present in aquaculture
biofilm fouling of the membrane present in aquacultureVINETUBE2
 
neural network non-linear hypothesis.pdf
neural network non-linear hypothesis.pdfneural network non-linear hypothesis.pdf
neural network non-linear hypothesis.pdfSamikshaGoel10
 
Introduction about Technology roadmap for Industry 4.0
Introduction about Technology roadmap for Industry 4.0Introduction about Technology roadmap for Industry 4.0
Introduction about Technology roadmap for Industry 4.0RaishKhanji
 
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEM
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEMMAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEM
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEMArunkumar Tulasi
 
Metrology Measurements and All units PPT
Metrology Measurements and  All units PPTMetrology Measurements and  All units PPT
Metrology Measurements and All units PPTdinesh babu
 
Nexus - Final Day 12th February 2024.pptx
Nexus - Final Day 12th February 2024.pptxNexus - Final Day 12th February 2024.pptx
Nexus - Final Day 12th February 2024.pptxRohanAgarwal340656
 
Introduction and replication to DragonflyDB
Introduction and replication to DragonflyDBIntroduction and replication to DragonflyDB
Introduction and replication to DragonflyDBMarian Marinov
 
Center Enamel is the leading bolted steel tanks manufacturer in China.docx
Center Enamel is the leading bolted steel tanks manufacturer in China.docxCenter Enamel is the leading bolted steel tanks manufacturer in China.docx
Center Enamel is the leading bolted steel tanks manufacturer in China.docxsjzzztc
 
MedTech R&D - Tamer Emara - resume @2024
MedTech R&D - Tamer Emara - resume @2024MedTech R&D - Tamer Emara - resume @2024
MedTech R&D - Tamer Emara - resume @2024Tamer Emara
 
GDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxGDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxAnandMenon54
 
Sample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeSample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeHarshith A S
 
Presentation of Helmet Detection Using Machine Learning.pptx
Presentation of Helmet Detection Using Machine Learning.pptxPresentation of Helmet Detection Using Machine Learning.pptx
Presentation of Helmet Detection Using Machine Learning.pptxasmitaTele2
 
CHAPTER 1_ HTML and CSS Introduction Module
CHAPTER 1_ HTML and CSS Introduction ModuleCHAPTER 1_ HTML and CSS Introduction Module
CHAPTER 1_ HTML and CSS Introduction Modulessusera4f8281
 

Recently uploaded (20)

20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt
20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt
20CE501PE – INDUSTRIAL WASTE MANAGEMENT.ppt
 
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...
Microstrip Bandpass Filter Design using EDA Tolol such as keysight ADS and An...
 
chap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignchap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processign
 
AC DISTRIBUTION - ELECTRICAL POWER SYSTEM
AC DISTRIBUTION - ELECTRICAL POWER SYSTEMAC DISTRIBUTION - ELECTRICAL POWER SYSTEM
AC DISTRIBUTION - ELECTRICAL POWER SYSTEM
 
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf
21 SCHEME_21EC53_VTU_MODULE-4_COMPUTER COMMUNCATION NETWORK.pdf
 
Series of training sessions by our experts for you to provide necessary insig...
Series of training sessions by our experts for you to provide necessary insig...Series of training sessions by our experts for you to provide necessary insig...
Series of training sessions by our experts for you to provide necessary insig...
 
Get start with Machine Learning and Vertexai
Get start with Machine Learning and VertexaiGet start with Machine Learning and Vertexai
Get start with Machine Learning and Vertexai
 
biofilm fouling of the membrane present in aquaculture
biofilm fouling of the membrane present in aquaculturebiofilm fouling of the membrane present in aquaculture
biofilm fouling of the membrane present in aquaculture
 
neural network non-linear hypothesis.pdf
neural network non-linear hypothesis.pdfneural network non-linear hypothesis.pdf
neural network non-linear hypothesis.pdf
 
Introduction about Technology roadmap for Industry 4.0
Introduction about Technology roadmap for Industry 4.0Introduction about Technology roadmap for Industry 4.0
Introduction about Technology roadmap for Industry 4.0
 
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEM
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEMMAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEM
MAXIMUM POWER POINT TRACKING ALGORITHMS APPLIED TO WIND-SOLAR HYBRID SYSTEM
 
Metrology Measurements and All units PPT
Metrology Measurements and  All units PPTMetrology Measurements and  All units PPT
Metrology Measurements and All units PPT
 
Nexus - Final Day 12th February 2024.pptx
Nexus - Final Day 12th February 2024.pptxNexus - Final Day 12th February 2024.pptx
Nexus - Final Day 12th February 2024.pptx
 
Introduction and replication to DragonflyDB
Introduction and replication to DragonflyDBIntroduction and replication to DragonflyDB
Introduction and replication to DragonflyDB
 
Center Enamel is the leading bolted steel tanks manufacturer in China.docx
Center Enamel is the leading bolted steel tanks manufacturer in China.docxCenter Enamel is the leading bolted steel tanks manufacturer in China.docx
Center Enamel is the leading bolted steel tanks manufacturer in China.docx
 
MedTech R&D - Tamer Emara - resume @2024
MedTech R&D - Tamer Emara - resume @2024MedTech R&D - Tamer Emara - resume @2024
MedTech R&D - Tamer Emara - resume @2024
 
GDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxGDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptx
 
Sample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeSample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its Outcome
 
Presentation of Helmet Detection Using Machine Learning.pptx
Presentation of Helmet Detection Using Machine Learning.pptxPresentation of Helmet Detection Using Machine Learning.pptx
Presentation of Helmet Detection Using Machine Learning.pptx
 
CHAPTER 1_ HTML and CSS Introduction Module
CHAPTER 1_ HTML and CSS Introduction ModuleCHAPTER 1_ HTML and CSS Introduction Module
CHAPTER 1_ HTML and CSS Introduction Module
 

Types of function call

  • 1. Function Call by Value & Reference By: Arijit Dhali
  • 2. Contents 2 User Defined Function Common Method of Swapping Integers Call by Value Call by Reference Differences Conclusion
  • 3. User Defined Function A user-defined function is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment. Syntax: return_type function_name (parameter list) { Function Body return statement; } 3
  • 4. Common Method of Swapping Two Integers 4 #include<stdio.h> main() { int x, y, z; printf (“n Enter the value of x: "); scanf ("%d", &x); printf (“n Enter the value of y: "); scanf ("%d", &y); z = x; x = y; y = z; printf ( "n After swap : x = %d, y = %d n", x, y); return 0; } Using Third Variable Source Code: Storing Value Storing Value Swap using 3rd Variable Declaring Variable
  • 6. 6 Call by Value The call by value method of passing argument to a function, copies the actual value of an argument into the formal parameter of the function. In this case, changed made to parameter inside the function had no effect on argument.
  • 7. 7 #include<stdio.h> void swapvalue(int x,int y); int main() { int a,b; printf(“n Enter two numbers: "); scanf("%d %d",&a,&b); printf(“n Before Swapping a=%d, b=%d n",a,b); swapvalue(a,b); printf(“n After Swapping a=%d, b=%d n",a,b); return 0; } void swapvalue(int x,int y) { int temp; temp=x; x=y; y=temp; return; } Source Code: Swap using 3rd Variable Function Definition Function Declaration Declaring Variable Function Calling Passing Variable
  • 9. 9 Call by Reference The Call by Reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to be parameter affect the passed argument. To pass the value by reference, argument pointers are passed to the functions just like any other value. So, accordingly you need to declare the function parameters as pointer types as in the following swap(), which exchanges the values of the two integer variables pointed to by its arguments.
  • 10. 10 #include<stdio.h> void swapreference(int *x,int *y); int main() { int a,b; printf(“n Enter two numbers: "); scanf("%d %d",&a,&b); printf(“n Before Swapping a=%d, b=%d",a,b); swapreference(&a,&b); printf(“n After Swapping a=%d, b=%d",a,b); return 0; } void swapreference(int *x, int *y) { int temp=0; temp=*x; *x=*y; *y=temp; return; } Source Code: Swapping address using 3rd Variable Function Calling Passing Address Function Definition along with defining Pointer Function Declaration Declaring Variable
  • 12. › The function is called by directly passing value of variable as argument. › We need to declare a general variable as function argument. › Changes made in the formal parameters will not be reflected in the actual parameters. It is because formal and actual parameters are stored in different locations. Call by Value v/s Call by Reference › The function is called by directly passing address of variable as argument. › We need to declare pointer variable as function argument. › Changes made in the formal parameters will be reflected in the actual parameters. It is because formal and actual parameters are stored in same locations. 12 Call by Value Call by Reference
  • 13. 13 Conclusion As the Conclusion , If we want to pass only the value of variable use ‘call by value’ approach, and if you want to see the change in the original value of the variable then use ‘call by reference’ approach.
  • 14. GRACIAS 14 Hope to see you again!!!