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

/*
WAP to illustrate working of call-by-reference method of a function invoking.
*/
#include<iostream.h>
#include<stdlib.h>
int main()
{
      system ("cls");
      void change(int &);     //notice prototype
      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 &a)
{     a = 20;
      cout<<"Value of orig in function change() is: "<<a<<"\n";
      return;
}


OUTPUT


Comments

Popular posts from this blog

WAP using a class to store price list of 5 items and to print the largest prices as well as the sum of all prices.

WAP that obtains the rotation factor and rotates the array as per it.

WAP to get roll numbers and marks of the student of a class (get from the user) and store these details into a file called Marks.dat