WAP to illustrate working of call-by-value method of a function invoking.
/*
WAP to illustrate working of call-by-value method of
a function invoking.
*/
#include<iostream.h>
#include<stdlib.h>
int main()
{
system
("cls");
void
change(int);
int orig
= 10; //original value is 10.
cout<<"The
original value is: "<<orig<<"\n";
change(orig);
cout<<"Value
after change() is over: "<<orig<<"\n";
return 0;
}
void change(int orig)
{ orig =
20; //value of orig (the formal
parameter) becomes 20.
cout<<"Value
of orig in function change() is: "<<orig<<"\n";
return;
}
OUTPUT
Comments
Post a Comment