Call-by-Ref-function in c .

In this session i have discussed call by ref function in C .


Before study the call by ref you must have knowladge of pointer so first study the pointer .

In call by ref , the original value can be changed or modified because we pass the reference or address . So the actual and formal both parameter contains the same address . So any value change inside the function it will reflect in both .


Example : Write a program that demonstrate the call by ref function .

  #includ<stdio.h> 
  void display(int*x);
  int main()
  {  
       int x;
       x=10;
       printf(" Value display from function\n ");
       display(&x);
       printf("\nValue display from x variable\n");
       printf("x : %d",x);
       return 0;
  }
  void display(int*x)
  {
      *x=*x+10;
      printf("x : %d",*x);
  }
  
  OUTPUT : Value display from function
           x : 20
           Value display from x variable
           x : 20
    


Welcome to AndroidATPoint.

back image                     next image