A program for pass by reference
/ passing parameters by reference
#include
using namespace std;
void duplicate (int& a, int& b, int& c)
{ a*=2; b*=2; c*=2;} int main ()
{ int x=1, y=3, z=7; duplicate (x, y, z); cout << "x=" << class="str">", y=" << class="str">", z=" <<> return 0;} Output:
x=2, y=6, z=14 ---------


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home