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
Post A Comment:
0 comments: