Why has the value of x,y,z changed even though the change occurred inside the function ? -2, y-6, z-14 paosing paranetere by reference Finclude

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.1: Providing Class I/o Capabilities
Problem 7E
icon
Related questions
Question
Why has the value of x,y,z changed even though the change
occurred inside the function ?
passing paranetere by reference
tinclude <iostream>
using namespace atd;
x-2, y-6, z-14
void duplicate (inté a, inta b, ints c)
a*=2;
b*-2;
c*-2;
int main ()
int x=1, y=3, z=7;
duplicate (X, y, 2):
cout « "x=" « x « ", y=" « y « , z=" « 2:
return 0;
O because the function call the value by reference rather than by value
because any change inside function will reflect to the orignal value in the main
function
because the pointer is used in this program
Transcribed Image Text:Why has the value of x,y,z changed even though the change occurred inside the function ? passing paranetere by reference tinclude <iostream> using namespace atd; x-2, y-6, z-14 void duplicate (inté a, inta b, ints c) a*=2; b*-2; c*-2; int main () int x=1, y=3, z=7; duplicate (X, y, 2): cout « "x=" « x « ", y=" « y « , z=" « 2: return 0; O because the function call the value by reference rather than by value because any change inside function will reflect to the orignal value in the main function because the pointer is used in this program
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning