Search This Blog

Friday 3 June 2016

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


No comments:

Post a Comment

How do I crack the GSOC in the field of machine learning?

How do I crack the GSOC in the field of machine learning? Working as a student at Google Summer of Code demands for your dedication an...