C++ Function Parameter reference
#include <iostream> using namespace std; void newval(double&, double&); // prototype with two reference parameters int main()//w ww . ja v a 2 s . c om { double firstnum, secnum; cout << "Enter two numbers: "; cin >> firstnum >> secnum; cout << "\nThe value in firstnum is: " << firstnum << endl; cout << "The value in secnum is: " << secnum << "\n\n"; newval(firstnum, secnum); // call the function cout << "The value in firstnum is now: " << firstnum << endl; cout << "The value in secnum is now: " << secnum << endl; return 0; } void newval(double& xnum, double& ynum) { cout << "The value in xnum is: " << xnum << endl; cout << "The value in ynum is: " << ynum << "\n\n"; xnum = 89.5; ynum = 99.5; return; }