Call by Value in C

In Call by Value, when a function is called, the value of the actual parameter is copied into the formal parameter. This means changes made to the formal parameter inside the function do not affect the actual parameter. It ensures data protection, as the original data remains unchanged.

Actual parameters are the values or variables passed to the function when it is called. Formal parameters are the variables defined in the function declaration and definition that receive the values of the actual parameters.

Let us see an example to implement Call by Value in C programming:

Output

In the changeValue() function, the x is assigned the value of a, which is 5. Then x is set to 10.

After calling the changeValue() function above, the value of a remains unchanged because changeValue() only modifies the copy of a (i.e., the parameter x).

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others:


For Videos, Join Our YouTube Channel: Join Now


Read More:

Loops in C Programming
Call by Reference in C
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading