int fun1(int a, int b) { a = a * 2; return a + b; } int fun2(int &a, int &b) { a = a - 2; b = b * 3; return b - a; } int main() { int x = 3, y = 12; int z = fun1(x, y); cout << fun2(z, y) << " "; cout << x << " " << y << " " << z; return 0; }
Added by Ian R.
Step 1
Then, the function fun1 is called with x and y as arguments. Inside fun1, a is assigned the value of x (which is 3) and b is assigned the value of y (which is 12). Then, a is multiplied by 2, so a becomes 6. The function then returns a + b, which is 6 + 12 = 18. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 71 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Suppose x, y, and z are double variables and x = 2.5, y = 6.9, and z = 10.0.What will be in the memory locations of each of the variables after each of the following statements is executed? (For each exercise, use the original declaration.) a. z *= y++ % 7; b. x = (int) y + (14 – z / 7); c. x = z / 3 * --y; d. z /= (int) y / x; e. z = x + y / 4;
What is the output of the following code: int x=15; if(x%2)cout<<++x; else cout<< x;
Neel P.
Consider the following code segment: X 23 z X MOD Y Which of the following initial values of the variable would result in the variable being set to after the code segment is executed?
Paul G.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD