Here is a C++ program to illustrate working of call by reference method
SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
void value(int &x)
{
x=20;
cout<<"Value of x in function : "<<x<<endl;
}
int main()
{
int x=10;
cout<<"Value of x before function call : "<<x<<endl;
value(x);
cout<<"Value of x after function call : "<<x;
return 0;
}
using namespace std;
void value(int &x)
{
x=20;
cout<<"Value of x in function : "<<x<<endl;
}
int main()
{
int x=10;
cout<<"Value of x before function call : "<<x<<endl;
value(x);
cout<<"Value of x after function call : "<<x;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment