programplug Logo

C Call By Value

original value is not modified

It is the default way of calling a function in C programming.In this method copies the actual value of an argument into the formal parameter of the function.
Means function creates a new set of variables and copies the values of the arguments into them.

int sum(int a, int b)
     int c=a+b;
     return c;

int main(
    int v1 = 20;
    int v2 = 20;
    int v3 = sum(v1,v2);
    printf("%d", v3);
    return 0;

In above a and b are the formal parameters.
Variable v1 and v2 are the actual arguments(parameters).

Example : Swapping numbers using Function Call by Value

void swap( int a, int b )
   int temp;
   temp = a;
   a = b;
   b = temp;
int main()
    int n1 = 10, n2 = 20 ;
    printf("Before swapping: %d,%d",n1,n2);
    swap(n1, n2);
    printf("\n After swapping: %d,%d",n1,n2);

Before swapping: 10, 20
After swapping: 10, 20

Our Services

Developing Cheapest Websites
Offer Digital Marketing
Provide College Projects
Attractive Website Developing
Summer Training,Industrial Training

Contact Us

Dehradun Uttarakhand India

Other Link

About Us

Contact Us


Privacy Policy