Write a C++ program that explain the call by value functionality.

Program Code:
#include <iostream>
using namespace std;

// function declaration 

void changeValue(int a);


// definition of main() function with function call to user defined function changeValue()

int main()
{
int a=50;
// call to user defined function in main()
changeValue(a);
cout << "The value of a is remain same after manipulation in function definition : " ;
cout<< a << "." ;
cout<< endl;
return 0;
}

// definition of user defined function which change the value

void changeValue(int value)
{
value = 600;
}

The program output is tested on www.jdoodle.com
Output:
The value of a is remain same after manipulation in function definition : 5


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: