Consider the following program. #include using namespace std; void summer(int&, int); void fall(int, int&); int x; int main() { int intNum1 = 2; int intNum2 = 5; x = 6; summer(intNum1, intNum2); cout << intNum1 << " " << intNum2 << " " << x << endl; fall(intNum1, intNum2); cout << intNum1 << " " << intNum2 << " " << x << endl; return 0; } void summer(int& a, int b) { int intNum1; intNum1 = b + 12; a = 2 * b + 5; b = intNum1 + 4; } void fall(int u, int& v) { int intNum2; intNum2 = x; v = intNum2 * 4; x = u - v; } Answer the following questions: a. What is the output? Consider variable scope. b. Considering the function summer, parameter 1 is called by reference. What is passed into the function for parameter 1, i.e., what value does parameter 1 receive? c. Again, considering the function summer, parameter 2 is called by value. What occurs in memory for parameter 2 and local variable int intNum1? Hint: consider memory, parameters and local variables

Question

2. Consider the following program.

#include <iostream>

using namespace std;

void summer(int&, int);

void fall(int, int&);

int x;

int main() {

int intNum1 = 2;

int intNum2 = 5;

x = 6;

summer(intNum1, intNum2);

cout << intNum1 << " " << intNum2 << " " << x << endl;

fall(intNum1, intNum2);

cout << intNum1 << " " << intNum2 << " " << x << endl;

return 0;

}

void summer(int& a, int b)

{

int intNum1;

intNum1 = b + 12;

a = 2 * b + 5;

b = intNum1 + 4;

}

void fall(int u, int& v)

{

int intNum2;

intNum2 = x;

v = intNum2 * 4;

x = u - v;

}

Answer the following questions:

a. What is the output? Consider variable scope.

b. Considering the function summer, parameter 1 is called by reference. What is passed into the function for parameter 1, i.e., what value does parameter 1 receive?

c. Again, considering the function summer, parameter 2 is called by value. What occurs in memory for parameter 2 and local variable int intNum1? Hint: consider memory, parameters and local variables

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: C++ code

A: C++ code for profile description for student are here:

Q: Use the master method to solve T(n) = 4T(n/2) + n2

A: Master method is a method for solving recurrences that arise frequently in divide and conquer algori...

Q: flowchart for this code       Declarations             num mortgagePayment             num utilities...

A: Main function flow chart:

Q: Make a code in C to detect that the Mario caught a mushroom. Set the x position of the shroud and th...

A: #include &lt;stdio.h&gt; int main(){int mario_size = 0;int shroud, mushroom;printf("Enter shroud ");...

Q: how do I enter the years row? The language is python

A: Code with correction: StartingSalary = int(input("Enter starting salary: "))perIncrease = int(input(...

Q: Thank you

A: def linear_Search(file, value): #function takes filename and searching value     f = open(file, 'r')...

Q: Assume a linked list contains following integers: 5, 2, 4, 6, 8, 3, 15 and the pointer head is point...

A: The linked list contains following integers: 5, 2, 4, 6, 8, 3, 15. The pointer “head” is pointing to...

Q: Go to the cw_home.html and cw_styles.css files and enter your name and the date in the comment secti...

A: Styles Navigation List At the bottom of the home page is a navigation list with the id #bottom conta...

Q: While troubleshooting an E-mail client issue on a user’s system, you that the incoming mail server s...

A: On the server, incoming e-mails will be processed. Using laptops and mobile devices to control onlin...