Call by value
Call by value is copying the value of a variable in another variable. So any change made in the copy will not affect the original location.
int a=10;
void fun(int a)
fun(a);
{
Definition;
}
Here, fun(a) is a call by value.
Note: Any change, which is done within the function is local and will not change the outside function.
Example:
#include<stdio.h>
void main()
{
int a=10; //a is read as 10
printf(“%d”,a);
fun(a);
printf(“%d”,a); //a is read as 10
}
void fun(int x) //x is read as 10
printf(“%d”,x);
x++;
printf(“%d”,x); //x is read as 11
}
OUTPUT
10 10 11 10