2. CALL BY VALUE AND CALL
BY REFERENCE
SUHANI VERMA
PALAK PARMAR
Member Name
Member Name Member Name
YATRI SHELDIYA
3. Call by Value
Introduction to Call Methods
Call by
Reference
Arguments
are passed by
copying their
values.
Arguments
are passed by
referencing
their memory
addresses.
4. Changes inside
the function do
not affect the
caller.
Usage
A copy of the
actual
parameter's value
is passed.
Definition Effect on
Parameters Commonly used
in C
programming for
simple data
types.
Overview of Call by Value
5. 3
1 2
Useful for reflecting changes
back to the caller.
Use Case
Passes the address of the
actual parameter.
Overview of Call by Reference
Definition
Allows direct modification of
the original variable.
Modification
6. CALL BY VALUE AND CALL BY REFRENCE IN C #
Original Value
Modified?
Call by value Call by refrence
NO YES
7. Feature Call by Value Call by Reference
Data Passing Copies the value Passes the address
Original Data Unchanged Can be modified
Memory Usage More memory for copies Less memory usage
Performance Slower for large data types Faster for large data types
Use Case Safe for small data types Useful for large data types
Key Differences
8. Example of Call by Value
#include <stdio.h>
void modifyValue(int num)
{
num += 10; // Modify the value
printf("Inside function: %dn", num);
}
int main()
{
int originalValue = 5;
printf("Before function call: %dn", originalValue);
modifyValue(originalValue); // Call the function
printf("After function call: %dn", originalValue);
return 0;
}
OUTPUT
9. 1 3
Example of Call by Reference
.
#include <stdio.h>
void addTen(int *num)
{
*num = *num + 10; // Modify the value at the address passed
}
int main()
{
int num = 5;
printf("Before function call: %dn", num);
addTen(&num); // Pass the address of num
printf("After function call: %dn", num); // num is modified
return 0;
}
OUTPUT
10. Essential for effective C
programming.
Each has its own use cases.
Conclusion
Knowing when to use each
method.
Advantages of Each
Method
Enhancing Coding Skills
Importance of
Understanding
11. We value your time and attention.
We hope this article aids your
understanding.
Appreciation
Learning Journey
Thank You