Here is a simple code which explains some basic concept
int add(int a, int b)//pass by value function
int addr(int *c,int *d)//pass by reference function
return( *c + *d );
printf("enter 2 digits");
printf("there sum is %d",add(a,b)); //invoking pass by value
int *p; //creating a pointer to variable
printf("\nmodified value of a is %d",a);
printf("\n using reference\n");
printf("%d",addr(&a,&b)); //invoking pass by reference function
But somehow, it did not work in linux. "using namespace std" did not help.
So, i thought of some online editor and it eased the job.
|Ide One compilation|
however similar thing in addr() affecting value of passed variable(as address of the variable is being passed and not the value of it.
The happiness to see the concepts being understood made me happy as well and scribble down the same scriplet here as well..