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, 22.06.2019 09:00
Which best describes the condition under which the unicode output is the same as plain text?
Answers: 3
question
Computers and Technology, 24.06.2019 19:30
Can someone who is skilled at coding create me a java chess game. don't copy from online source codes. make it original ! : d
Answers: 1
question
Computers and Technology, 25.06.2019 08:50
The purpose of this problem is to write some small functions and practice passing things around amoung functions.1) the main function shall ask the user to enter three numbers and read the three numbers.2) write a function named findsum that takes three numbers as arguments and returns their sum. the main function shall call this function.3) write a function named findaverage that takes the sum and the number of numbers and returns the average. the main function shall call this function.4) write a function named findsmallest that takes the three numbers and returns the smallest value. the main function shall call this function.5) the main function shall print the results in the following format, with two decimal positions and the decimal points aligned:
Answers: 3
question
Computers and Technology, 25.06.2019 17:30
You are thinking of hiring a security monitoring service . you can pay a flat rate of $100 per month or pay $200 per incident you expect to average one incident per 3 months which plan will be cheaper
Answers: 2
You know the right answer?
Consider the following program. Assume all variables are declared and the program compiles. #includ...
Questions
question
Advanced Placement (AP), 18.03.2021 02:10
question
Health, 18.03.2021 02:10
question
Social Studies, 18.03.2021 02:10
question
Biology, 18.03.2021 02:10
question
History, 18.03.2021 02:10
Questions on the website: 13722360