Monday 24 July 2017

Program to illustrate working of call-by-reference method of a function invoking.

PROGRAM
Program to illustrate working of call-by-reference method of a function invoking.

    #include<iostream.h>
    #include<conio.h>
    #include<stdlib.h>
      int main()

        {  system("cls");
            void change(int&);
            int orig = 10;
            cout<<"The original value is : "<<orig<<"\n";
            change(orig);
           cout<<"Value after change() is over : "<< orig<<"\n";
              getch();
              return 0;
          }
      void change(int& a)
        { a=20;
           cout<<"Value of orig in function change() is : "<<a<<"\n";
           return ;
         }
========================================================================
 OUTPUT:
 The original value is : 10
 Value of orig in function change() is : 20
 Value after change() is over : 20

========================================================================

No comments:

Post a Comment