Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:00, mrnotsosmart744
Discuss the ways in which electronic information associated with payments is addressed in terms of security. include encryption, secure sockets layers, and secure electronic transactions in your discussion. are there any other ways that consumers and businesses can keep their payment information secure in an electronic commerce environment? do you feel that your information is safe when conducting electronic business? why or why not?
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, Disd112984
Which statement is true of web-based social media? a. they allow consumers to interact with and update content. b. they cannot be updated easily, as compared to print media. c. they are expensive to produce and maintain, as compared to print and television. d. they can exist independent of the internet.
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, alangonsales6232
2. fluorine and chlorine molecules are blamed fora trapping the sun's energyob forming acid rainoc producing smogod destroying ozone molecules
Answers: 2
image
Computers and Technology, 24.06.2019 04:30, minecrafter3882
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
Do you know the correct answer?
Consider the following program. Assume all variables are declared and the program compiles. #includ...

Questions in other subjects:

Konu
Social Studies, 11.01.2021 17:00