subject

Consider the following program. Assume all variables are declared and the program compiles. #include
using namespace std;

void getVal(int&, int&);
void procVal(int, int&);

int x;

int main() {
int intNum1;
int intNum2;
x = 6;

getVal(intNum1, intNum2);
cout << intNum1 << " " << intNum2 << " " << x << endl;

procVal(intNum1, intNum2);
cout << intNum1 << " " << intNum2 << " " << x << endl;
return 0;
}
void getVal(int& a, int& b)
{
cout << “Enter value for a: “ << endl;
cin >> a; /// The user enters 1
cout << “Enter value for b: “ << endl;
cin >> b; /// The user enters 2
x = a * b;

}
void procVal(int u, int& v)
{
int intNum3;
intNum3= x;
v = intNum3 * 4;
u = u - v;
}

Answer the following questions:

a. What is the output in the cout statements? Consider variable scope.

b. Considering the function getVal, both parameters are called by reference. What is passed into the function for the parameters, i. e., what do the parameters receive? HINT: Do not write ‘a reference parameter or a reference value’!

c. Considering the function procVal, parameter 1 is called by value. What occurs in memory for parameter 1 and local variable int intNum3? Hint: consider memory, parameters and local variables

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 21:30
Examine the list below. which factors positively affect lifetime income? check all that apply.
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You will subnet the network address 172.31.103.0/24. the network has the following requirements: · room-114 lan will require 27 host ip addresses · room-279 lan will require 25 host ip addresses · room-312 lan will require 14 host ip addresses · room-407 lan will require 8 host ip addresses how many subnets are needed in the network topology?
Answers: 2
question
Computers and Technology, 25.06.2019 02:00
Software and services are used to conceive, plan, and execute projects in any field. these tools are excellent methods of increasing the probability of successful projects. open source linux project management mind-mapping
Answers: 2
question
Computers and Technology, 25.06.2019 08:20
E-commerce builds on traditional commerce by adding the flexibility that networks offer and the availability of the internet. - true or false
Answers: 1
You know the right answer?
Consider the following program. Assume all variables are declared and the program compiles. #includ...
Questions
question
Mathematics, 30.11.2020 22:10
question
Health, 30.11.2020 22:10