This is what I understand call by value and call by address
OutputCode:#include<stdio.h>
void bar ( int fvar)
{
fvar++;
}
void foo ( int *ptr)
{
*ptr = 1000; // This line change value of y
}
int main()
{
int x = 1;
int y = 100;
printf(" value of x before to functional call is %d \n", x);
printf(" value of y before to functional call is %d \n", y);
bar (x) ; // pass value of variable x to function bar
printf(" value of x after function call is %d \n", x);
foo (&y); // pass address of variable y to function foo
printf(" value of y after to function call is %d \n", y);
return 0;
}
Code:
value of x before to functional call is 1
value of y before to functional call is 100
value of x after function call is 1
value of y after to function call is 1000