When a function is called, any arguments that are provided by the caller are simply treated as expressions in programming languages.

The value of each expression has the appropriate conversion applied and is then used to initialize the corresponding formal in the called function,

which behaves exactly the same way as any other local variables in the function. Calling a function by passing the value of an actual argument is called a call by value.

C++ Program to call by value function program

using namespace std;
void swap(int a, int b) { 
int z; z = a; a=b; b=z; } 
int main(){ 
int a = 33, b = 35;
cout<<"Before :"<<a<<","<<b<<endl;
cout<<"After :"<<a<<","<<b; return 0;

Output:-Before :33,35
After :33,35

Explanation of the program

Here, the function is called by the value which means that the value of the arguments is passed on to the function.

This article is written by our awesome writer
Comments to: Call by value function in C++ with example

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password